#C8419. Two Sum Problem

    ID: 52399 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

Given an array of integers (A) of length (n) and a target integer (T), find two distinct indices (i) and (j) (using 0-indexing and with (i < j)) such that (A[i] + A[j] = T). It is guaranteed that exactly one solution exists for each input case. The answer should be output as the two indices in ascending order.

inputFormat

The first line contains an integer (n), the number of elements in the array.\nThe second line contains (n) space-separated integers representing the array (A).\nThe third line contains an integer (T), the target sum.

outputFormat

Output two space-separated integers which are the indices of the two numbers that add up to (T), in ascending order.## sample

4
2 7 11 15
9
0 1