#K34882. Two Sum Indices
Two Sum Indices
Two Sum Indices
Given an array of integers and an integer \( target \), find two distinct indices \( i \) and \( j \) such that \( nums[i] + nums[j] = target \). It is guaranteed that exactly one solution exists. The answer should output the two indices in ascending order.
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains an integer \( n \), representing the number of elements in the array.
- The second line contains \( n \) space-separated integers, which are the elements of the array \( nums \).
- The third line contains an integer \( target \), representing the target sum.
outputFormat
Output two integers representing the indices of the two numbers that sum to \( target \) in ascending order, separated by a single space, via standard output (stdout).
## sample4
2 7 11 15
9
0 1
</p>