Search⌘ K
AI Features

Solution: Single Number II

Explore how to identify two unique numbers in an array where all others appear twice, using bitwise XOR operations. This lesson helps you understand grouping by set bits and applying XOR to isolate unique values efficiently with constant extra 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 ...