#C12470. Two Sum Problem
Two Sum Problem
Two Sum Problem
Given an array of integers \( nums \) and an integer \( target \), find two distinct indices \( i \) and \( j \) such that:
[ nums[i] + nums[j] = target ]
It is guaranteed that there is exactly one solution. You may not use the same element twice, and the order of the returned indices does not matter.
Note: The indices are 0-indexed.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains two integers \( n \) and \( target \), where \( n \) is the number of elements in the array.
- The second line contains \( n \) space-separated integers representing the array \( nums \).
outputFormat
Output the two indices (0-indexed) separated by a space to standard output (stdout). If the answer is \( i \) and \( j \), you should output:
i j## sample
4 9
8 2 7 11
1 2