Tag view

#hash-map

Cross-subject tag search for related interview cards.

Clear

Results update as you type. Press / to jump straight into search.

Tagged with hash-map

11 cards

Coding Exercises Easy O(n)

Anagram Check

Either sort both strings and compare them, or build character frequency maps. The hash-map version is linear time and communicates counting skill well.

Check whether two strings contain the same characters with the same counts.

Coding Exercises Easy O(n)

Count Word Frequency

Split the text into words, normalize if needed, and increment counts in a dictionary. Python collections.Counter is great, but interviewers may ask for the manual version first.

Return a frequency map for the words in a sentence.

Coding Exercises Easy O(n)

First Non-Repeating Character

Build a frequency map for the characters, then iterate through the string a second time to return the first character whose count is one.

Return the first character in a string that appears exactly once, or an empty string if none exists.

Coding Exercises Medium O(n * k log k)

Group Anagrams

Use a dictionary keyed by the sorted characters of each word, then append each word into the matching bucket.

Group words that are anagrams of each other and return the grouped lists.

Coding Exercises Medium O(1)

LRU Cache

Store items in an OrderedDict, move keys to the end whenever they are read or updated, and evict the oldest item when capacity is exceeded.

Implement an LRU cache with O(1) get and put operations.

Coding Exercises Hard O(n + m)

Minimum Window Substring

Track how many required characters are satisfied as you grow the right edge. Once the window is valid, shrink from the left to find the smallest valid window before expanding again.

Return the smallest substring of s that contains all characters from t.