1/7
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress

Two Sum
Hashmap value → index
For each x, compute target - x
If exists in map → return indices
Else store x → i
O(n)

Ransom Note
Char frequency count:
Count chars in magazine
For each char in ransomNote, decrement
If any count < 0 → false
Can use array of size 26

Group Anagrams
Hash by normalized key:
Sort string OR use 26-char frequency tuple
Map key → list of strings
Return all groups

Insert Delete GetRandom O(1) (LC380)
Use array + hashmap
Map: value → index
Insert → append to array, store index
Remove → swap with last element, pop
Update hashmap
GetRandom → random index from array
All ops O(1)

First Missing Positive (H)
Index placement trick:
While 1 <= x <= n and not in correct position → swap to x-1
After pass, first index i where nums[i] != i+1 → answer i+1
Else return n+1
In-place, O(n)

LRU Cache
Hashmap + Doubly Linked List:
Map key → node
DLL keeps order (most recent at front)
Get → move node to front
Put → insert/update at front
If over capacity → remove tail
All ops O(1)

All O(1) Data Structure (AllOne) (H)
Hashmap + Doubly Linked List of counts:
Map key → node (node stores count)
DLL stores buckets of same count
Inc/Dec → move key to next/prev count bucket
Remove empty buckets
Head = min, Tail = max
All ops O(1)

Design and Implement LFU Cache (H)
Hashmap + frequency lists:
Map key → (value, freq)
Map freq → DLL of keys
Track minFreq
Get → increase freq, move key to next freq list
Put → if full, evict from minFreq list (LRU within same freq)
Insert new key with freq = 1
All ops O(1)