#C497. Two Sum Indices Problem

    ID: 48566 Type: Default 1000ms 256MiB

Two Sum Indices Problem

Two Sum Indices Problem

Given an array of integers \(nums\) and an integer \(target\), find two distinct indices \(i\) and \(j\) (with \(i < j\)) such that \(nums[i] + nums[j] = target\). If such a pair exists, output the two indices; otherwise, output \(-1 -1\).

The input is provided as follows: the first integer denotes the number of elements \(n\), followed by \(n\) integers representing the array elements, and finally the integer \(target\). The output should be two integers separated by a space.

Note: If there are multiple valid pairs, output the one found first using a left-to-right scan.

inputFormat

The first number is an integer \(n\) indicating the size of the array. The next \(n\) numbers are the elements of the array \(nums\). The last number is the integer \(target\).

outputFormat

Print two integers separated by a space representing the indices \(i\) and \(j\) (with \(i < j\)) such that \(nums[i] + nums[j] = target\). If no such pair exists, output "-1 -1".

## sample
6
2 7 11 15 1 8
9
0 1

</p>