#K43502. Two Sum Problem

    ID: 27323 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

Given an array of integers \(A = [a_0, a_1, \ldots, a_{n-1}]\) and an integer target \(T\), your task is to find two distinct indices \(i\) and \(j\) such that \(a_i + a_j = T\). It is guaranteed that there is exactly one solution for each test case.

Your solution should be efficient and use standard input/output for I/O operations.

inputFormat

The input is given in three lines:

  1. The first line contains an integer (n), representing the number of elements in the array.
  2. The second line contains (n) space-separated integers, the elements of the array.
  3. The third line contains an integer (T), the target sum.

outputFormat

Output a single line with two space-separated integers representing the indices (0-indexed) of the two numbers in the array that add up to (T).## sample

4
2 7 11 15
9
0 1