Subject: PHP

Find Pairs with a Given Sum

Write a PHP function to find all pairs of integers in an array whose sum is equal to a given target.

Example:
Input: Array: [1, 2, 3, 4, 5], Target: 6
Output: [(1, 5), (2, 4)]

Select file or drag and drop

PNG, JPG, SVG

Preview