#C13994. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given an array of integers and a target integer, your task is to find two distinct indices \(i\) and \(j\) (with \(i < j\)) such that the sum of the elements at these indices equals the target.
Each input is guaranteed to have exactly one solution, and the same element cannot be used twice. The indices are zero-based.
Example: For the input array [2, 7, 11, 15] and target 9, the output should be 0 1 since \(2 + 7 = 9\).
inputFormat
The input is given via stdin in the following format:
n num_1 num_2 ... num_n target
Where n is the number of elements in the array, the next line contains n space-separated integers representing the array, and the last line contains the target integer.
outputFormat
Output via stdout two space-separated integers representing the indices of the two numbers in the array whose sum equals the target.
## sample4
2 7 11 15
9
0 1