#K72397. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given an array of integers and a target value, your task is to find the indices of the two numbers in the array such that they add up to the target. Formally, for an array a[0], a[1], ..., a[n-1] and a target T, you need to find indices i and j satisfying
\( a_i + a_j = T \)
It is guaranteed that each input will have exactly one solution, and you may not use the same element twice. Read the input from standard input and output the two indices separated by a space to standard output.
inputFormat
The input is given via standard input and has the following format:
- The first line contains an integer n, the number of elements in the array.
- The second line contains n space-separated integers representing the array.
- The third line contains an integer T representing the target sum.
outputFormat
Output to standard output two integers separated by a space, which are the indices of the two numbers in the array that add up to the target sum.
## sample4
2 7 11 15
9
0 1