Unique Number
EasyPractice library · +10 XPbit manipulationxor tricksbeginner
Given a list of N integers, where exactly one integer appears only once and all other integers appear exactly twice, find and print the integer that appears only once.
Input
The first line contains an integer N. The second line contains N space-separated integers.
Output
Print the integer that appears only once.
Constraints
1 <= N <= 1000. All integers will be between 0 and 1000 inclusive.
Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests
Example 1
Input
5 1 2 3 2 1
Output
3
3 is the only number that appears once.
Example 2
Input
3 7 7 4
Output
4
4 is the only number that appears once.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
5 1 2 3 2 1
Example 2 input
3 7 7 4