You get an array of integers and a target. Return indices of two numbers that add to target.
Brute force: try every pair. Works, but O(n²). Interviews want the O(n) story.
As you scan left→right, ask: "Have I already seen target - nums[i]?"
Keep a hash map: value → index.
nums = [2,7,11,15], target = 9
You already solved this on LeetCode. Rewrite it cleanly here without peeking.
Tip: Open the Animated Classroom for Two Sum — watch the map fill before you code.
Input
4 9 2 7 11 15
Output
0 1
Input
3 6 3 2 4
Output
1 2