Search⌘ K
AI Features

Single Number II

Explore how to use bitwise manipulation to find two elements that appear only once in an array where others appear twice. Understand the problem constraints and implement an efficient solution in C++ using 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 ...