Tap here to switch tabs
Problem
Submissions

Problem: Single Number II

Single Number II gives an array where exactly two values appear once and every other value appears twice. Return the two unique values in either order 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:

  • 2≤2 \leq arr.length ≤103\leq 10^3

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Single Number II

Single Number II gives an array where exactly two values appear once and every other value appears twice. Return the two unique values in either order 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:

  • 2≤2 \leq arr.length ≤103\leq 10^3

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