#C1412. Two Sum Problem
Two Sum Problem
Two Sum Problem
You are given an array of integers and an integer (target). Your task is to find two distinct indices (i) and (j) such that (nums[i] + nums[j] = target). If such a pair exists, output the indices separated by a space; otherwise, output -1.
The input is provided via standard input, and the output must be printed to standard output. If there are multiple valid answers, any valid pair is acceptable.
inputFormat
The input will be provided through standard input (stdin) in the following format:
1. The first line contains an integer (n), which is the number of elements in the array.
2. The second line contains (n) space-separated integers representing the array (nums).
3. The third line contains an integer (target), which is the target sum.
outputFormat
Output two distinct indices separated by a space if a valid pair exists that sums to (target). If no such pair exists, output -1.## sample
4
2 7 11 15
9
0 1
</p>