Find the two values that appear exactly once when every other value appears twice.
You are given an integer array in which exactly two numbers appear once and every other number appears exactly twice.
Return the two unique numbers in any order.
A good solution should use constant extra space and run in linear time.
nums.Return an array containing the two numbers that appear once, in any order.
Example 1
Input
[1,2,1,3,2,5]
Output
[3,5]
Explanation
The numbers 3 and 5 appear once. The others appear twice.
Example 2
Input
[-1,0,-1,4]
Output
[0,4]
Explanation
The values 0 and 4 occur only once.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.