← 返回 amazon 的题目列表Find All Unique Index Pairs Summing to Target Value
类型:online_judge
amazon
Write a function that takes an array of integers and a target value as parameters, and returns all unique index pairs whose sum equals the target value. Each element in the array can be used only once in each pair. Assume each input has exactly one solution and there are no duplicate elements in the array.
Test Cases
Input: nums = [2, 7, 11, 15], target = 9, Output: [(0, 1)]
Input: nums = [1, 5, 3, 4], target = 6, Output: [(0, 2), (2, 3)]
Input: nums = [3, 3], target = 6, Output: [(0, 1)]
Input: nums = [1, 2, 3, 4, 5], target = 10, Output: [(3, 4)]
Input: nums = [-1, 0, 1, 2, -1, -4], target = -2, Output: [(0, 4)]
Example
Input
2
7
11
15
9