#C4413. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given a list of integers and an integer target, find the indices of the two numbers such that they add up to target. It is assumed that each input has exactly one solution. If a pair is not found, output -1.
The input is provided via STDIN. The first line contains two integers: n (the number of elements) and target, separated by a space. The second line contains n space-separated integers.
The output should be printed to STDOUT. If a valid pair is found, print the two 0-indexed positions separated by a space; otherwise, print -1.
inputFormat
The first line of input contains two integers n and target, where n represents the number of integers in the list. The second line contains n space-separated integers.
outputFormat
If there exists a pair of numbers in the list that sums up to target, output their indices (0-indexed) separated by a space. If no such pair exists, output -1.
## sample4 9
2 7 11 15
0 1