Walk the array once; for each element check if (target − value) is in the hash table, otherwise insert. Live hash table visible.
Find two indices whose values sum to a target. The brute-force approach checks every pair in O(N²). A one-pass hash map records the indices of values we have already seen. For each new element, we look up its complement (target − value) in O(1). If the complement is present, we have the answer immediately. Otherwise we insert the current value and keep going.
For each value x at index i, the answer is "did I previously see a value equal to target − x?". A hash map of value → index makes that lookup O(1). The first time the complement is present in the map, we have the pair.
Order matters. For each element x: (1) compute complement = target − x, (2) check if complement is already a key in the map, and if yes, return [seen[complement], i], (3) only AFTER the lookup, insert seen[x] = i. Inserting first would let the algorithm match an element with itself.
Brute force tries every pair (i, j), which is O(N²) comparisons. Trading O(N) extra space for the hash map collapses each pair check into a single O(1) lookup, so the whole pass is O(N).
The same value-to-index hash-map pattern shows up in problems like "subarray sum equals K" (prefix sums), "contains duplicate within k", and "longest substring without repeating characters". Whenever you need to ask "have I seen X before, and where?", a hash map is the right tool.