#C502. Find Pair Sum
Find Pair Sum
Find Pair Sum
You are given an array of integers and an integer target. Your task is to find two distinct indices \(i\) and \(j\) such that the sum of the corresponding elements equals the target, i.e., \(a_i + a_j = target\). It is guaranteed that each input would have exactly one solution, and you may not use the same element twice.
The problem needs to be solved with efficient methods, preferably in \(O(n)\) time using a hash table.
inputFormat
The first line contains an integer (n), the number of elements in the array.\nThe second line contains (n) space-separated integers.\nThe third line contains an integer representing the target sum.
outputFormat
Output the two indices (0-indexed) separated by a space. The order of indices should correspond to the order in which the pair is found in the array.## sample
4
2 7 11 15
9
0 1