HashMap & Set

Two Sum

easy
Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`. You may assume each input has exactly one solution, and you may not use the same element twice. Return the answer in any order. Prefer a one-pass HashMap approach. Example: `twoSum([2,7,11,15], 9)` → `[0,1]`.
Hint steps(0/3 revealed)
  1. 1

    Complete previous step or reveal to unlock this hint.

  2. 2

    Complete previous step or reveal to unlock this hint.

  3. 3

    Complete previous step or reveal to unlock this hint.