Medium

Quiz

#260 Single Number III

APPROACH

In the integer array nums, every element appears exactly twice except for two elements, each of which appears only once. Identify those two unique elements and return them in any order.

Your algorithm must run in linear time and use only constant extra space.

Example 1:

Input: nums = [1,2,1,3,2,5]
Output: [3,5]
Explanation: [5, 3] is also a valid answer.

Example 2:

Input: nums = [-1,0]
Output: [-1,0]

Example 3:

Input: nums = [0,1]
Output: [1,0]
1 of 4
1:00

What is the optimal approach for this problem?