Two Sum

Easy
ArrayHash TableGoogleAmazon
Given an array of integers and a target, print the zero-based indices of two numbers whose sum equals the target. Input format: - First line: n target - Second line: n integers Print two indices in increasing order. If multiple pairs work, print the lexicographically smallest pair.

Constraints

2 <= n <= 10^5
-10^9 <= nums[i], target <= 10^9
Exactly one valid pair exists.

Sample tests

Sample 1

Sample 2

Sign in to submit