Leetcode: Two Sum (JS)

Example 1:

Understanding the problem:

Per the example above, if we start with 2, and we want to reach 9 — we need to add 7 from the array. The indices for 2 and 7 are 0 and 1.

How do we do this?

Another Solution:

✨✨✨And that’s it!

Tish⚡️🎧🌙

--

--

MHA grad & Software Engineer | Rails | React | JavaScript | CSS | HTML

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tish Faroul

MHA grad & Software Engineer | Rails | React | JavaScript | CSS | HTML