#1

Two Sum

Easy
All Problems

1. Two Sum#1

Easy📊 Arrays & HashingHash Map Lookup

Given an array of integers and a target, return the indices of two numbers that add up to the target.

Examples

Example 1:
Input: [[2,7,11,15],9]
Output: [0,1]
Example 2:
Input: [[3,2,4],6]
Output: [1,2]
Example 3:
Input: [[3,3],6]
Output: [0,1]

Why learn this

THE most famous LeetCode problem. Teaches the fundamental hash map lookup pattern used everywhere.

ArraysHash MapsComplement Pattern
Python 3Loading Python engine...
Click "Run Code" to test your solution