CodeMentor.
Ask AIProblemsLearnC++TCSCore CSHRProgress
0Lv 1
ProblemsArrays

Single Number

Easy
LeetCode
9/14
EasyArraysLeetCode #136

Single Number

Every element appears twice except one. Find it in O(n) time O(1) space.

The move

XOR cancels pairs: a^a=0, a^0=a.

Examples

Example 1

Input

3
2 2 1

Output

1
Example 2

Input

5
4 1 2 1 2

Output

4

Stuck? Take a nudge

C++17Autosaves