#C12107. Two Sum Problem

    ID: 41498 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

You are given an integer array and an integer target. Your task is to find two different numbers in the array such that their sum is equal to the target. If such a pair exists, output the indices (0-indexed) of the two numbers. Otherwise, output an empty list []. The solution should ideally have a time complexity of O(n). The input is provided via standard input and the output should be printed to standard output.

inputFormat

The input consists of three parts provided through standard input:

  • 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 a single integer representing the target sum.

outputFormat

If a valid pair is found, output the two indices separated by a space on a single line. If no such pair exists, output [].

## sample
4
2 7 11 15
9
0 1