#K64402. Two Sum Challenge
Two Sum Challenge
Two Sum Challenge
You are given an array of integers and a target value \(\tau\). Your task is to find two distinct indices \(i\) and \(j\) in the array such that:
\(nums[i] + nums[j] = \tau\)
If such a pair exists, output the indices \(i\) and \(j\) (0-indexed). If no such pair exists, output \(-1 -1\).
You can assume that each input will have at most one valid pair.
inputFormat
The input is given via standard input and consists of three lines:
- The first line contains a single integer \(n\) representing the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the elements of the array.
- The third line contains a single integer \(\tau\) representing the target value.
outputFormat
Output the two indices separated by a space if a valid pair exists. Otherwise, output -1 -1
.
The answer should be printed via standard output.
## sample4
2 7 11 15
9
0 1