Search⌘ K
AI Features

Solution: Single Number II

Understand how to identify two unique numbers in an array where all other elements appear twice by applying bitwise XOR operations. Explore the step-by-step algorithm that uses the rightmost set bit to partition the array, enabling separation and detection of the two distinct elements efficiently with constant space.

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 ...