#C4810. Two Sum Problem

    ID: 48390 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

Given an array of integers and a target integer \(T\), find two distinct indices \(i\) and \(j\) such that \(arr[i] + arr[j] = T\). If such a pair exists, output the indices as space-separated values in a single line. Otherwise, output \(-1\).

If multiple solutions exist, you may output any one of them.

inputFormat

The input consists of three lines:

  • The first line contains an integer \(n\) \( (1 \le n \le 10^5)\), the number of elements in the array.
  • The second line contains \(n\) space-separated integers representing the array elements.
  • The third line contains an integer \(T\), the target sum.

outputFormat

If a valid pair exists, output the two zero-indexed positions separated by a space. If no such pair exists, output \(-1\).

## sample
4
2 7 11 15
9
0 1

</p>