All problems
MediumData Structures
Two-sum (find pair summing to target)
Given a list of integers and a target, return indices of two numbers that sum to the target. Aim for O(n).
- #lists
- #dicts
- #algorithms
Sample input
[2, 7, 11, 15], target=9
Sample output
[0, 1]
two-sum.py
Output
Press "Run code" to execute.
