#K39197. Two Sum: Find Indices with Target Sum
Two Sum: Find Indices with Target Sum
Two Sum: Find Indices with Target Sum
Given an array of integers nums and an integer target, find two distinct indices \(i\) and \(j\) such that \(nums[i] + nums[j] = target\). If no such pair exists, output -1 -1
.
Note that the indices are zero-based.
inputFormat
The first line contains an integer n
, representing the number of elements in the array.
The second line contains n
space-separated integers representing the array elements.
The third line contains the integer target
.
outputFormat
Output two space-separated integers representing the indices of the two numbers that add up to the target. If no such pair exists, output -1 -1
.
4
2 7 11 15
9
0 1
</p>