Problem statement
You are given an array and a target, and exactly one pair of indices holds values that add up to it. Return those two indices.
Each index may be used once, and the pair is reported as positions rather than values.
Examples
Input[2, 7, 11, 15], target = 9
Output0 and 1
2 plus 7 is 9, and the pair is found at the second cell.
Input[3, 3], target = 6
Output0 and 1
Two equal values are a valid pair when they sit at different indices.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing