Problem
Ask
Submissions

Problem: Single Number II

Medium
30 min
Explore how to use bitwise manipulation to find two elements that appear once in an array while all others appear twice. Learn to solve this problem efficiently using constant extra space and improve your algorithm skills with coding practice.

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 arr.length 103\leq 10^3

  • 231−2^{31} \leq arr[i] 2311\leq 2^{31}-1

Problem
Ask
Submissions

Problem: Single Number II

Medium
30 min
Explore how to use bitwise manipulation to find two elements that appear once in an array while all others appear twice. Learn to solve this problem efficiently using constant extra space and improve your algorithm skills with coding practice.

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 arr.length 103\leq 10^3

  • 231−2^{31} \leq arr[i] 2311\leq 2^{31}-1