#K69682. Find Two Sum Indices

    ID: 33141 Type: Default 1000ms 256MiB

Find Two Sum Indices

Find Two Sum Indices

Given an array \(A\) of \(n\) integers and an integer \(target\), find two distinct indices \(i\) and \(j\) such that \(A[i] + A[j] = target\). The output should be the indices in ascending order formatted as a Python list. If no such pair exists, output an empty list.

You are required to implement a solution that efficiently finds the pair using a hash map (i.e. in approximately \(O(n)\) time complexity). If multiple answers exist, returning any valid one is acceptable.

inputFormat

The input is given via stdin and consists of:

  1. An integer \(n\) representing the number of elements in the array.
  2. \(n\) space-separated integers representing the array \(A\).
  3. An integer \(target\) representing the target sum.

For example: 5\n2 7 11 15 -2\n9\n

outputFormat

Output the result to stdout as a Python list representation. If a valid pair is found, output the sorted indices enclosed in square brackets, for example: [0, 1]. If no such pair exists, output [].

## sample
5
2 7 11 15 -2
9
[0, 1]