#K41257. Two Sum Problem

    ID: 26825 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

Given an array of integers, your task is to find two distinct numbers whose sum equals a given target value. Return the indices of these two numbers as a pair, where the indices are zero-based. If no such pair exists, output nothing.

The problem can be mathematically stated as follows: Given an array (A = [a_0, a_1, \dots, a_{n-1}]) and a target integer (T), find indices (i, j) such that (a_i + a_j = T).

inputFormat

The input consists of three lines:

  1. The first line contains an integer (n), representing the number of elements in the list.
  2. The second line contains (n) space-separated integers.
  3. The third line contains a single integer representing the target value.

outputFormat

If a valid pair exists, output the two indices separated by a space. If multiple solutions exist, output the first valid pair found. If no valid pair exists, output nothing.## sample

4
2 7 11 15
9
0 1

</p>