Search⌘ K
AI Features

Solution: Single Number II

Understand how to use bitwise XOR operations to separate two unique elements from duplicates in an array. This lesson guides you through identifying the rightmost set bit and partitioning the array to find both unique numbers with constant extra space and linear time complexity.

Statement

Given a non-empty array arr, in which exactly two elements appear once, and all the other elements appear twice, return the two elements that appeared only once.

Note: The result can be returned in any order. The solution should use only constant extra space.

Constraints:

  • 22 \leq ...