Twin Coins (Arrays & Lists)

Read n, n integers and a target. Print the 0-based indices i j (i < j) of the first pair (smallest j, then smallest i) that adds up to the target, or none.

Input: n, the numbers, then the target.

Output: i j or none.

Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • A map from value to its first index finds the pair in one pass.

More Arrays & Lists practice