← 返回 microsoft 的题目列表Hash Map Counting / Lookup Problem
类型:online_judge
Problem: Hash Map Lookup (Two Sum Variant)
Given an integer array nums and an integer target, find two distinct indices whose values sum to target.
Print the two indices (0-based). If multiple answers exist, print any. If none exists, print -1 -1.
Input
Line 1: integer n
Line 2: n integers nums[i]
Line 3: integer target
Output
Two indices i j with i != j, or -1 -1
Constraints
2 <= n <= 2 * 10^5
-1e9 <= nums[i], target <= 1e9
Example
Input:
4
2 7 11 15
9
Output:
0 1
Example
Input
4
2 7 11 15
9
Output
0 1