Problem 60927. Pairs with Given Sum
Given an array of integers and a target sum, return all unique pairs whose sum is equal to the target. The output should be a matrix with 2 columns representing each pair.
Assume pairs are unordered, i.e., (2, 3) and (3, 2) are considered the same pair.
- try to maintain the sequence as the numbers appear in the input array.
Solution Stats
Problem Comments
-
1 Comment
Dyuman Joshi
6 hours and 1 minute ago
This questions lacks good test cases.
Inline to that - many solutions submitted use nchoosek(), which would be inefficient (both time and memory wise) for arrays with a good number elements (say even n>500, as 500C2 = 124750).
Solution Comments
Show commentsProblem Recent Solvers10
Suggested Problems
-
10 Solvers
More from this Author174
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!