#C12323. Two Sum Problem

    ID: 41738 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

Given an array of integers \(nums\) and an integer \(target\), find the indices of the two numbers such that they add up to \(target\). If such a pair does not exist, output -1. The indices should correspond to the positions of the numbers in the original array.

You can assume that each test case contains at most one valid solution.

inputFormat

The input is provided via standard input (stdin). The first line contains two integers: (n), the number of elements in the array, and (target), separated by a space. The second line contains (n) space-separated integers representing the elements of the array.

outputFormat

Output the indices of the two numbers that add up to (target) as two space-separated integers on a single line. If no such pair exists, output -1.## sample

4 9
2 7 11 15
0 1