#K89357. Two Sum Problem
Two Sum Problem
Two Sum Problem
You are given a list of integers and a target integer \( T \). Your task is to find the indices of the two numbers in the list whose sum is equal to \( T \). Assume that each input has exactly one solution, and you may not use the same element twice.
Note: The indices of the numbers in the list are zero-based. For example, if the list is [2, 7, 11, 15] and \( T = 9 \), the solution is indices [0, 1] because \( 2 + 7 = 9 \).
Your solution should read input from stdin
and write the result to stdout
.
inputFormat
The input consists of three lines:
- The first line contains an integer \( n \) representing the number of elements in the list.
- The second line contains \( n \) space-separated integers, representing the elements of the list.
- The third line contains a single integer \( T \), the target sum.
outputFormat
Output a single line with two space-separated integers representing the indices of the two numbers such that their sum equals \( T \). The indices should be printed in ascending order if that is the order found by your solution.
## sample4
2 7 11 15
9
0 1
</p>