#C13788. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given a list of integers and a target integer, find two distinct numbers in the list such that their sum is equal to the target. The answer should be the 1-indexed positions of these two numbers.
More formally, for a given list \(a_1, a_2, \dots, a_n\) and an integer \(target\), you need to find indices \(i\) and \(j\) (with \(i \neq j\)) such that:
\[ a_i + a_j = target \]It is guaranteed that there is exactly one solution for each input, and you may not use the same element twice.
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains an integer \(n\) representing the number of elements in the list.
- The second line contains \(n\) space-separated integers.
- The third line contains an integer representing the \(target\) sum.
outputFormat
Output to standard output (stdout) two space-separated integers corresponding to the 1-indexed positions of the two numbers which add up to the \(target\). There will always be a unique solution.
## sample4
2 7 11 15
9
1 2
</p>