easy
Single Number
In a non-empty integer array every element appears exactly twice except one, which appears once. Find that element in linear time using constant extra memory.
Constraints
- 1 ≤ n ≤ 3 · 10^4
- -3 · 10^4 ≤ nums[i] ≤ 3 · 10^4
- Exactly one element appears once
Examples
in: nums = [4,1,2,1,2]
out: 4
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.