← 返回 amazon 的题目列表Two Sum Variant
类型:online_judge
amazon
Given an integer array nums and an integer target, find indices of the two integers such that they add up to target. Assume that each input has exactly one solution, but you may return multiple possible combinations. Elements of the array cannot be reused. Note that the output should be ordered in ascending index order. If no such combinations exist, return an empty list.
Input Description:
An integer array nums of length n.
An integer target.
Output Description:
If there exists one or more combinations, return a list of indices for these combinations, with each combination as a small list, sorted in ascending order; otherwise, return an empty list.
Data Range:
1 <= nums.length <= 10^4
-10^9 <= nums[i] <= 10^9
-10^9 <= target <= 10^9
Example:
Input:
nums = [2, 7, 11, 15]
target = 9
Output:
[[0, 1]]
Example
Input
nums = [2, 7, 11, 15]
target = 9