FastPrepAll Distinct Target-Sum Pairs
Problems/All Distinct Target-Sum Pairs

All Distinct Target-Sum Pairs

Expedia logoExpedia● MediumNEW GRADINTERNOAONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for all pairs that add up to a target, using nonnegative values, and has a follow-up about duplicate input. We chose to use pairs of distinct values, the order of the pairs, and the limits. Our version is about 90% the same as the reported question.

Given an array nums of nonnegative integers and a nonnegative integer target, return every distinct value pair whose sum is the target. Each pair must use two different input positions.

Write each pair as [smaller, larger], and return pairs in lexicographic order. Repeated index choices do not create repeated value pairs. A pair [x,x] requires at least two copies of x. Return an empty array when no pair exists.

Function

allUniquePairs(nums: int[], target: int) → int[][]

Examples

Example 1

nums = [1,2,3,2,4,0]target = 4return = [[0,4],[1,3],[2,2]]

The three distinct value pairs sum to 4. Two copies of 2 make [2,2] valid.

Example 2

nums = [1,1,1]target = 2return = [[1,1]]

Repeated index choices do not create additional value-pair results.

Constraints

  • 0 <= nums.length <= 100000.
  • 0 <= nums[i] <= 1000000000.
  • 0 <= target <= 2000000000.

Interview reports that mention this question

  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
  • Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)
  • Expedia New Grad SDE Earlier Loops: 5 Experiences (Part 2 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
See Expedia hiring insights
Saved
class Solution {
    public int[][] allUniquePairs(int[] nums, int target) {
      // Write your code here.
    }

}
Checking account…