FastPrepUnique Pairs With Target Sum
Problems/Unique Pairs With Target Sum

Unique Pairs With Target Sum

Amazon logoAmazon● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given an array of integers, nums, and an integer target.

Find every pair of values from nums that add up to target. Write each pair with the smaller value first. If the same pair of values can be made more than once, list it only once. Pairs are counted by value, not by position.

A pair can use the same value twice if that value appears at least twice in nums.

Return the pairs as a list of [a, b] lists, in lexicographic order. That means smaller first value first, and for the same first value, smaller second value first. If no pair adds up to target, return an empty list.

For example, if nums = [1, 4, 2, 3, 3, 2, 0, 5] and target = 5, the pairs are [0, 5], [1, 4] and [2, 3]. The pair [2, 3] is listed once, even though both 2 and 3 appear twice.

Function

uniquePairs(nums: int[], target: int) → List<List<Integer>>

Examples

Example 1

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

The pairs that add up to 5 are 0 + 5, 1 + 4 and 2 + 3. The values 2 and 3 each appear twice, but the pair [2, 3] is listed only once. In order, the answer is [[0, 5], [1, 4], [2, 3]].

Example 2

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

The two largest values are 3 and 4, and they add up to only 7. No pair reaches 10, so the answer is the empty list [].

Constraints

  • 1 <= nums.length
  • -2^31 <= nums[i] <= 2^31 - 1
  • -2 * 10^9 <= target <= 2 * 10^9

More Amazon Phone Screen questions

  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
  • Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
  • Second Largest Distinct ElementPHONE SCREEN · Seen Nov 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · Seen Nov 2026
  • Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Sparse Vector Dot ProductWhatNot · PHONE SCREENWhatNot interview questions
  • Repeated Shortest Word Distance QueriesLinkedIn · PHONE SCREENLinkedIn interview questions
  • Disjoint Target-Sum TripletsAmerican Express · PHONE SCREENAmerican Express interview questions
  • Sparse Vector Dot ProductAnduril · PHONE SCREENAnduril interview questions
  • Sparse Vector Dot Product from TuplesMeta · ONSITE INTERVIEWMeta interview questions
  • Count Cross-Array Target-Sum PairsVisa · OAVisa interview questions
  • Two SumMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Find Two-Sum or Three-Sum Index CombinationsGoogle · ONSITE INTERVIEWGoogle interview questions

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public List<List<Integer>> uniquePairs(int[] nums, int target) {
        // write your code here
    }

}
Checking account…