#C6631. Two Sum Problem

    ID: 50413 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

You are given a list of integers and a target integer \(T\). Your task is to find two distinct indices \(i\) and \(j\) such that:

\(nums[i] + nums[j] = T\)

If such a pair exists, output the two indices (0-indexed) separated by a single space. If there is no solution, output None.

It is guaranteed that each test case contains at most one valid solution based on the way the algorithm processes the list. Note that the order of indices in the output must conform to the discovered order.

inputFormat

The input is read from stdin and consists of three lines:

  • The first line contains an integer \(n\) indicating the number of elements in the list.
  • The second line contains \(n\) space-separated integers.
  • The third line contains an integer representing the target value \(T\).

outputFormat

Output to stdout a single line. If a valid pair exists, print the two indices separated by a single space. Otherwise, print None (without quotes).

## sample
4
2 7 11 15
9
0 1