Data Structures19 sections · 729 units
Open in Course

Problem - Two Sum

Classic hash map

Given an array of integers numsnums and an integer targettarget, return indices of the two numbers that add up to targettarget.

Each input has exactly one solution, and you can't use the same element twice. You're implementing the most famous hash map problem. It's LeetCode problem #1 for a reason. Everyone should be able to solve it in under five minutes.