Two Sum

EasyHashing
Next
ArrayHash Map

Given an array of integers and a target, find the two different positions whose values add up to the target. Exactly one valid pair exists for every input.

Input

Line 1: n, the number of elements. Line 2: n space-separated integers. Line 3: the target integer.

Output

Print the two zero-based indices in ascending order, separated by a space.

Constraints

2 <= n <= 10^4 -10^9 <= each value, target <= 10^9

Example 1
Input
4
2 7 11 15
9
Output
0 1

2 + 7 = 9, at indices 0 and 1.

Example 2
Input
3
3 2 4
6
Output
1 2

2 + 4 = 6, at indices 1 and 2.

Hints

Two Sum - Easy Hashing Problem | Skill Shiksha