#C13249. Find Two Sum Indices

    ID: 42766 Type: Default 1000ms 256MiB

Find Two Sum Indices

Find Two Sum Indices

Given an array of integers, your task is to find two distinct indices \(i\) and \(j\) such that the sum of the corresponding elements equals a given target. In other words, find indices \(i, j\) satisfying

$$a_i + a_j = target$$

It is guaranteed that each input has exactly one solution, and the same element cannot be used twice.

inputFormat

The input is provided via stdin and consists of three lines:

  1. The first line contains an integer \(n\), the number of elements in the array.
  2. The second line contains \(n\) space-separated integers representing the array elements.
  3. The third line contains an integer representing the target value.

outputFormat

Output the two indices (0-indexed) separated by a space in a single line. The indices correspond to the two array positions whose values sum to the target.

For example, if the answer is indices 0 and 1, the output should be:

0 1
## sample
4
2 7 11 15
9
0 1