Problem
Ask
Submissions

Problem: Single Number II

Medium
30 min
Explore how to solve problems by finding two elements that appear only once in an array where all others appear twice. Learn to apply bitwise operations efficiently using constant extra space, developing problem-solving skills useful in coding interviews and algorithm optimization.

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 solve problems by finding two elements that appear only once in an array where all others appear twice. Learn to apply bitwise operations efficiently using constant extra space, developing problem-solving skills useful in coding interviews and algorithm optimization.

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