Given an array of integers and a target, find two different positions whose values add up to the target. If several pairs work, choose the one with the smallest first index, then the smallest second index.
Input: line 1 — space-separated integers; line 2 — the target.
Output: the two indices i j (i < j, 0-based) separated by a space, or -1 if no pair exists.
Your program reads from stdin and prints to stdout.
Example 1
Input: 2 7 11 15 9
Output: 0 1
Hints
Given an array of integers and a target, find two different positions whose values add up to the target. If several pairs work, choose the one with the smallest first index, then the smallest second index.
Input: line 1 — space-separated integers; line 2 — the target.
Output: the two indices i j (i < j, 0-based) separated by a space, or -1 if no pair exists.
Your program reads from stdin and prints to stdout.
Example 1
Input: 2 7 11 15 9
Output: 0 1
Hints