← 返回 amazon 的题目列表Two Sum
类型:online_judge
Given an integer array nums and an integer target, return the indices of two distinct elements such that they add up to target.
Assume that each input has exactly one solution, and the same element cannot be used twice. The answer can be returned in any order.
Input Format
The first line contains two integers n and target.
The second line contains n integers representing nums.
Output Format
Print two integers representing the indices of the two elements. Indices are 0-based. The order does not matter.
Constraints
2 <= n <= 10^5
-10^9 <= nums[i] <= 10^9
-10^9 <= target <= 10^9
Exactly one valid answer exists.
Example
Input:
4 9
2 7 11 15
Output:
0 1
Example
Input
4 9
2 7 11 15
Output
0 1