#K1926. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given an array of n integers and a target value \(T\), find two distinct indices \(i\) and \(j\) (with \(i < j\)) such that the sum of the elements at these indices equals \(T\). It is guaranteed that exactly one solution exists. Your task is to read the input from stdin and output the two indices (separated by a space) to stdout.
Example:
Input: 4 2 7 11 15 9</p>Output: 0 1
The indices are zero-based.
inputFormat
The input is read from stdin 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 elements of the array.
- The third line contains the target integer \(T\).
outputFormat
Output to stdout two space-separated integers which are the indices of the two numbers in the array that add up to the target. It is assumed that there is exactly one solution.## sample
4
2 7 11 15
9
0 1
</p>