The Lonely Number
Every value appears exactly twice, except one that appears once. Find it — ideally without extra memory.
Input: the first line has N (odd); the second line has N positive integers.
Output: the value that appears once.
Constraints:
- 1 ≤ N ≤ 105
- 1 ≤ ai ≤ 106
Sample Tests
Input 1
5 2 3 5 3 2
Output 1
5
Input 2
1 42
Output 2
42
Discussion (opens after you solve — no spoilers before)
No comments yet.