Mental Model
We find two numbers that add up to a target by remembering numbers we've seen before and checking if the partner number is already known.
Analogy: Imagine you want to buy two items that together cost exactly your budget. You keep a list of prices you've seen and check if the price needed to reach your budget is already on your list.
nums: [2, 7, 11, 15]
hash_map: {}
We scan nums left to right, adding each number to hash_map with its index.
For each number, we check if target - number is in hash_map.