#C4846. Find Pair with Sum

    ID: 48429 Type: Default 1000ms 256MiB

Find Pair with Sum

Find Pair with Sum

Given an array of integers and a target integer, your task is to find two distinct elements in the array whose sum is equal to the target value. Output the indices of the two numbers (0-indexed) if such a pair exists; otherwise, print -1.

You are expected to design an efficient solution with an average time complexity of \(O(n)\). Note that if multiple pairs exist, output the pair that is found first by scanning the array from left to right.

inputFormat

The first line contains two integers \(n\) and \(target\), where \(n\) denotes the number of elements in the array.

The second line contains \(n\) space-separated integers representing the elements of the array.

outputFormat

If a pair of numbers adding up to \(target\) is found, print their indices separated by a space. If no such pair exists, print -1.

## sample
4 9
2 7 11 15
0 1