Heap and Frequency • Intermediate • 20 min
Top K Frequent Elements
How to count frequency first and then choose only the top K efficiently.
Practice problems with walkthroughs, hints, and solutions.
Filter by type or level
Heap and Frequency • Intermediate • 20 min
How to count frequency first and then choose only the top K efficiently.
Stack • Intermediate • 15 min
How to keep the minimum updated in O(1) with a simple helper structure instead of scanning the whole stack.
Stack • Intermediate • 15 min
How to compose two stacks to simulate a queue and understand why lazy transfer keeps the amortized cost low.
Dynamic Programming • Intermediate • 18 min
How to model the choice between robbing or skipping each house while respecting the adjacency constraint.
Search • Intermediate • 22 min
How to adapt binary search when the full order is broken by a rotation but not completely gone.
Backtracking • Intermediate • 25 min
How to explore paths in a grid, mark the current choice, and undo that choice on the way back.
Data Structure Design • Intermediate • 30 min
How to combine a hash map with a doubly linked list for fast lookup and fast recency updates.
Graphs • Intermediate • 25 min
How to turn prerequisites into a directed graph and detect when a dependency comes back to itself.
Backtracking • Intermediate • 20 min
How to use counter-based backtracking to prune invalid prefixes before they turn into wasted work.
Strings and Expansion • Intermediate • 22 min
How to notice that every palindrome has a center and use that to avoid a heavier [dynamic programming](/glossary/dynamic-programming) solution than necessary.
Dynamic Programming • Intermediate • 22 min
How to turn string segmentation into prefix [dynamic programming](/glossary/dynamic-programming) instead of retrying the same cut over and over.
Arrays and Two Pointers • Advanced • 28 min
How to notice that water at each position depends on both side maximums and compress that into [two pointers](/glossary/two-pointers).
Sliding Window • Advanced • 30 min
How to turn "does it contain everything?" into a satisfaction condition and shrink the window only while it stays valid.
Matrix • Intermediate • 20 min
How to decompose a matrix rotation into simpler transformations and do it in place with clear coordinate mapping.
Dynamic Programming • Intermediate • 25 min
How to turn comparison between two strings into a table of subproblems instead of repeating [recursion](/glossary/recursion) choices.
Matrix • Intermediate • 20 min
How to walk a matrix in layers using clear top bottom left right boundaries instead of scattered conditions.
Trees • Advanced • 30 min
How to turn a tree into a string and back while preserving the null markers that define its shape.
Heap • Advanced • 25 min
How to keep the median ready by splitting the lower half and upper half with two [heap](/glossary/heap) structures.
Dynamic Programming • Intermediate • 22 min
How to start from [O(n²)](/glossary/o-n-squared) [dynamic programming](/glossary/dynamic-programming) and reach the idea of smallest possible endings with [binary search](/glossary/binary-search).
Graphs • Intermediate • 20 min
How to deep-copy a graph with cycles by keeping a clear mapping from old nodes to new ones.
Trees • Intermediate • 18 min
How to search for a real subtree by comparing shape and values, not just roots that seem to match.
Trees • Intermediate • 15 min
How to use inorder traversal to exploit the BST ordering and stop as soon as the counter reaches k.
Intervals • Intermediate • 20 min
How to find how many meetings are active at the same time by tracking starts and ends in order.
Graphs • Advanced • 30 min
How to extract letter constraints from sorted words and turn them into a [topological sort](/glossary/topological-sort).