FastPrepFind the Unpaired Numbers
Problems/Find the Unpaired Numbers

Find the Unpaired Numbers

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem asks for the one or two values of an array that have no partner when every other value appears exactly twice. An Adobe Computer Scientist 1 report lists both versions, each only as a link, among the DSA questions of a first round that accepted pseudocode, and its author adds that the two-value version is hard without bit-manipulation practice.

Our choices: one problem covers both versions through k (1 or 2), the answers come in increasing order, there are at most 2002 values from -10^9 to 10^9, and the examples are new. The constant-memory goal is stated but not judged.

The judged task matches the report at about 85%.

In the array nums, almost every value has a partner: it appears exactly twice. Exactly k values have no partner and appear only once, where k is 1 or 2.

Return the k unpaired values in increasing order.

Try to use only a constant amount of extra memory besides the input.

Function

unpairedNumbers(nums: int[], k: int) → int[]

Examples

Example 1

nums = [7,3,5,3,7]k = 1return = [5]

3 and 7 each appear twice; 5 appears once.

Example 2

nums = [4,-6,9,4,2,9]k = 2return = [-6,2]

4 and 9 appear twice. The two values that appear once are -6 and 2, returned in increasing order.

Example 3

nums = [0]k = 1return = [0]

A single value is unpaired.

Constraints

  • k is 1 or 2
  • nums.length == 2 * m + k for some 0 <= m <= 1000
  • -10^9 <= nums[i] <= 10^9
  • Exactly k values appear once in nums, and every other value appears exactly twice.

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public int[] unpairedNumbers(int[] nums, int k) {
    // Write your code here.
}
Checking account…