#C13865. Two Sum

    ID: 43450 Type: Default 1000ms 256MiB

Two Sum

Two Sum

You are given an array of integers and a target integer. Your task is to find the indices of the two numbers in the array that add up to the target. You may assume that each input has exactly one solution, and you cannot use the same element twice.

Important: The indices of the numbers are 0-indexed. Print the two indices separated by a single space to stdout.

Example: For the array [2, 7, 11, 15] with target 9, the correct output is "0 1" because 2 + 7 = 9.

The solution uses a hash table approach with time complexity \(O(n)\). In your solution, you must read input from stdin and write the answer to stdout.

inputFormat

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

outputFormat

Output a single line with two space-separated integers representing the indices of the two numbers that add up to the target.## sample

4
2 7 11 15
9
0 1