Hashmap / Frequency Counting / Hash Set Reasoning
This category teaches why hash-based lookup is powerful: some problems become frequency ledgers, some become bijections, some become complement search, and some become cycle or membership reasoning.
Store the latest index for each number, then let every repeat instantly measure its gap to the previous occurrence and compare that gap with k.
Normalize each word into a sorted signature and use that signature as the hash-map key. Words with identical signatures collapse into the same group.
Transform the number into the sum of the squares of its digits and use a hash set to decide whether the sequence converges to 1 or loops forever.
Walk the strings together and enforce a one-to-one character mapping in both directions. The first mismatch or target collision ends the trace.
Deduplicate values into a set, then expand consecutive runs only from numbers whose predecessor is missing. That single idea is what makes the solution linear.
Build a frequency table from the magazine, then spend those counts while the ransom note asks for letters. The moment a count hits zero too early, the answer becomes false.
Scan the array once, compute the missing complement for the current value, and let the hash map tell you whether that partner has already appeared.
Visualize the classic two-pass frequency trick: count characters from the first string, then cancel those counts using the second string until the ledger balances or breaks.
Treat each pattern letter like a symbol that must consistently map to one whole word, while each word stays owned by exactly one symbol.