#K73037. Two Sum Problem

    ID: 33886 Type: Default 1000ms 256MiB

Two Sum Problem

Two Sum Problem

Given an array of integers and a target value, your task is to find two distinct indices such that the numbers at those indices add up to the target. You may assume that each input has exactly one solution and that you may not use the same element twice.

The solution should be efficient, ideally using a hash table approach. In other words, find indices i and j (with i < j) such that:

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

Input is provided via standard input (stdin) and output should be written to standard output (stdout) as described below.

inputFormat

The input consists of three lines:

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

outputFormat

Output two space-separated integers representing the indices of the two numbers that add up to the target. It is guaranteed that a unique solution exists.

## sample
4
2 7 11 15
9
0 1