mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-10-25 17:42:27 +08:00
* refactor: clean to roadmap content * refactor: move shared helpers into scripts/lib
685 B
685 B
Two Sum
You are given an array of integers and a target number. The goal is to find two numbers in the array that add up to the target and return their positions. The naive approach checks every pair, but the key insight is using a hash map to store numbers you have already seen, bringing the solution from O(n²) down to O(n). This problem teaches the core habit of trading space for time, a trade-off you will use constantly in harder problems.
Visit the following resources to learn more: