SDE Path

Two Sum Problem

Easy

Two Sum Problem

Given an array and a target, determine whether any two elements sum to the target and return their indices.

Input format

The first line contains N and the target. The second line contains N space-separated integers.

Output format

Print the two 0-based indices i j (i < j) whose values sum to the target. If several pairs exist, print the one with the smallest j, then smallest i. If no pair exists, print -1.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
4 9
2 7 11 15
Expected output
0 1
Example 2
Input
3 6
3 2 4
Expected output
1 2