Back

Interview Prep / Two Sum

00:00
1/20

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.

  • 1

    Use a Map to store the difference between the target and the current number.

  • 2

    If the current number is in the map, you've found the pair!

JAVASCRIPT PLAYGROUND
JAVASCRIPT PLAYGROUND
⏳ Loading editor…