Hash-Table
LeetCode 981: Time Based Key-Value Store
·2 mins
LeetCode
Medium
Hash-Table
String
Binary-Search
Design
LeetCode 981 note: store a (timestamp, value) list per key, with timestamps increasing; get binary searches the last timestamp <= the query
LeetCode 424: Longest Repeating Character Replacement
·2 mins
LeetCode
Medium
Hash-Table
String
Sliding-Window
LeetCode 424 note: a variable sliding window where window length minus the top character count is the number of replacements; shrink when it exceeds k
LeetCode 347: Top K Frequent Elements
·1 min
LeetCode
Medium
Array
Hash-Table
Divide-and-Conquer
Sorting
LeetCode 347 note: count first, then take the k most frequent with a size-k heap or a bucket sort indexed by count
LeetCode 128: Longest Consecutive Sequence
·2 mins
LeetCode
Medium
Array
Hash-Table
Union-Find
LeetCode 128 note: put everything in a set and count upward only from values whose x - 1 is absent; each value is seen at most twice, O(n)
LeetCode 73: Set Matrix Zeroes
·2 mins
LeetCode
Medium
Array
Hash-Table
Matrix
LeetCode 73 note: record which rows and columns contain a 0 first, then update afterward; the follow-up uses the first row and column as markers
LeetCode 49: Group Anagrams
·2 mins
LeetCode
Medium
Array
Hash-Table
String
Sorting
LeetCode 49 note: use each string’s sorted form as a key; strings sharing a key form one anagram group
LeetCode 36: Valid Sudoku
·2 mins
LeetCode
Medium
Array
Hash-Table
Matrix
LeetCode 36 note: each digit may appear once per row, column and 3 × 3 box; put (digit, row), (digit, column) and (digit, box) keys into one set
LeetCode 17: Letter Combinations of a Phone Number
·2 mins
LeetCode
Medium
Hash-Table
String
Backtracking
LeetCode 17 note: each level handles one digit and tries its letters; an empty input returns an empty list
LeetCode 1189: Maximum Number of Balloons
·2 mins
LeetCode
Easy
Hash-Table
String
Counting
LeetCode 1189 note: each letter supports count // needed balloons, with l and o needed twice; take the minimum
LeetCode 1160: Find Words That Can Be Formed by Characters
·1 min
LeetCode
Easy
Array
Hash-Table
String
Counting
LeetCode 1160 note: a word is formable when none of its character counts exceeds chars’; sum the lengths of such words
LeetCode 1128: Number of Equivalent Domino Pairs
·2 mins
LeetCode
Easy
Array
Hash-Table
Counting
LeetCode 1128 note: normalize each domino to (small, large) as a key and count; a key with c dominoes yields c(c - 1) / 2 pairs
LeetCode 1122: Relative Sort Array
·1 min
LeetCode
Easy
Array
Hash-Table
Sorting
Counting-Sort
LeetCode 1122 note: count first, emit values in arr2’s order, then append the remaining values in ascending order