BackmediumTwo Pointers Oracle

Pair Sum Combinations Solution

Problem Statement

Given an array of distinct integers `numbers` and a target sum `sumTarget`, find all pairs of unique elements in `numbers` that add up to `sumTarget`. Return the pairs of elements that sum up to `sumTarget`.

Example 1
Input
{"numbers":[1,2,3,4,5],"sumTarget":7}
Output
[[2,5],[3,4]]

Explanation: The pairs (2, 5) and (3, 4) sum up to 7.

Example 2
Input
{"numbers":[-1,0,1],"sumTarget":0}
Output
[[-1,1]]

Explanation: The pair (-1, 1) sums up to 0.

Constraints

  • 1 <= length of `numbers` <= 10^4
  • -10^9 <= each element in `numbers` <= 10^9
  • 1 <= `sumTarget` <= 2 * 10^9
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free