Hashmap / Frequency Counting / Hash Set Reasoning

Hashmap

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.

Contains Duplicate II

easy

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.

Open visualizer

Group Anagrams

medium

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.

Open visualizer

Happy Number

easy

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.

Open visualizer

Isomorphic Strings

easy

Walk the strings together and enforce a one-to-one character mapping in both directions. The first mismatch or target collision ends the trace.

Open visualizer

Longest Consecutive Sequence

medium

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.

Open visualizer

Ransom Note

easy

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.

Open visualizer

Two Sum

easy

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.

Open visualizer

Valid Anagram

easy

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.

Open visualizer

Word Pattern

easy

Treat each pattern letter like a symbol that must consistently map to one whole word, while each word stays owned by exactly one symbol.

Open visualizer