#K88397. Two Sum Pair Indices
Two Sum Pair Indices
Two Sum Pair Indices
You are given an array of integers and a target integer. Your task is to find the indices of the two numbers in the array such that their sum is equal to the target. The indices must be printed in ascending order.
Explanation:
- Let the array be \( nums \) and the target be \( target \).
- You need to find two indices \( i \) and \( j \) (with \( i < j \)) such that \( nums[i] + nums[j] = target \).
You can assume that each input will have exactly one solution, and you may not use the same element twice.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \( n \) (the number of elements in the array).
- The second line contains \( n \) space-separated integers representing the array \( nums \).
- The third line contains a single integer \( target \) which is the target sum.
outputFormat
Print two space-separated integers, which are the indices (in ascending order) of the two numbers in the array whose sum is equal to \( target \). The output is written to standard output (stdout).
## sample4
2 7 11 15
9
0 1