#C13278. Find Two Sum Indices

    ID: 42798 Type: Default 1000ms 256MiB

Find Two Sum Indices

Find Two Sum Indices

You are given a list of integers and a target integer. Your task is to find the indices of the two numbers in the list that add up exactly to the target. Each input is guaranteed to have exactly one solution, and you may not use the same element twice.

Note:

The indices are based on 0-indexing.

The underlying idea is to use a hash table (or dictionary) to track the numbers you have seen so far and quickly determine if the complement (i.e. \(target - num\)) exists in the collection. The algorithm typically runs in \(O(n)\) time where \(n\) is the length of the list.

inputFormat

The input consists of two lines:

  • The first line contains space separated integers representing the list.
  • The second line contains a single integer denoting the target sum.

outputFormat

Output two space separated integers: the indices of the two numbers that add up to the target value. The output should be printed on one line.

## sample
2 7 11 15
9
0 1