#C5462. Two Sum
Two Sum
Two Sum
Given an array of integers and an integer target, your task is to find the indices of the two numbers such that they add up to the target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Mathematically, you need to find indices i and j that satisfy:
\(nums[i] + nums[j] = target\)
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains two integers \(n\) and \(target\), where \(n\) denotes the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array.
It is guaranteed that there exists exactly one solution.
outputFormat
Output to standard output (stdout) the two indices (0-indexed) of the numbers such that they add up to \(target\), separated by a single space.
## sample4 9
2 7 11 15
0 1