#K93287. Find the Pair

    ID: 38386 Type: Default 1000ms 256MiB

Find the Pair

Find the Pair

Given an array of n integers and a target integer \(T\), determine if there exist two distinct elements in the array such that their sum equals \(T\). Formally, find indices \(i\) and \(j\) (with \(i \neq j\)) such that \(a_i + a_j = T\). If such a pair exists, output the two indices in ascending order in the format [i, j]; otherwise, output an empty array [].

inputFormat

The input is given via stdin in the following format:

  1. The first line contains two space-separated integers: \(n\), the number of elements in the array, and \(T\), the target integer.
  2. The second line contains \(n\) space-separated integers representing the array elements.

outputFormat

Print the result to stdout as follows:

  • If a valid pair is found, print the two indices (in ascending order) in the format [i, j].
  • If no such pair exists, print [].
## sample
4 9
2 7 11 15
[0, 1]

</p>