#K4701. Find Pair Sum
Find Pair Sum
Find Pair Sum
You are given an array of integers and a target integer \( T \). Your task is to find two distinct indices \( i \) and \( j \) in the array such that:
[ nums[i] + nums[j] = T ]
If such a pair exists, output the two indices (0-indexed) separated by a space. Otherwise, output []
.
Note: Each input will contain exactly one test case. Make sure you read from standard input and write your result to standard output.
inputFormat
The first line contains an integer \( n \), the number of elements in the array. The second line contains \( n \) integers separated by spaces. The third line contains the target integer \( T \).
For example:
4 2 7 11 15 9
outputFormat
If a pair exists, output the two indices \( i \) and \( j \) (0-indexed) separated by a space. If no such pair exists, output []
.
4
2 7 11 15
9
0 1