Pairs with Given Sum - MATLAB Cody - MATLAB Central

Problem 60927. Pairs with Given Sum

Difficulty:Rate
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

85.71% Correct | 14.29% Incorrect
Last Solution submitted on Jun 13, 2025

Solution Comments

Show comments

Problem Recent Solvers9

Suggested Problems

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!