PROBLEM LINKS
DIFFICULTY
EASY
EXPLANATION
No real tricks here. An easy approach is to create a boolean array b[] of size n where item b[i] is true if and only if i does not appear in the input list. Make two passes through the array, each time keeping track of the number of "true" items seen so far. When an entry i is hit such that b[i] is true, output i if and only if the number of true items seen so far is odd/even depending on whether it is the first/second pass.