Lessons
Learn algorithm patterns step by step with clear explanations and examples.
Start here
Sliding Window
Step 1 of 8 · Find the Maximum Sum of k Consecutive Elements
Recommended Lessons
Two Pointers
Solve array/string problems in one pass by moving two indices instead of nesting loops.
Hash Map
Use a hash map as fast memory: scan once, look up what you need in O(1) average time.
Bipartite Matching
Find the maximum number of pairings between two disjoint sets. Use augmenting paths to re-route when direct matches conflict.
DP 1D
Build solutions incrementally using a 1D array where each element depends on previous elements.
DP 2D
Build solutions using a 2D table where dp[i][j] represents the answer for a subproblem defined by two parameters.
Heap
A specialized tree structure that provides O(log n) insertion and O(1) access to the minimum or maximum element. Essential for 'top K' and priority-based problems.
Trie
A tree structure for efficient string prefix operations. Enables O(m) search, insert, and prefix queries where m is the string length.
Linked List
Manipulate nodes by rewiring pointers rather than shifting elements. Master traversal, reversal, and the fast/slow pointer trick.
Sorting: Basics (Insertion Sort)
Build a sorted array one element at a time by inserting each element into its correct position. O(n²) worst case, but O(n) on nearly-sorted data.
String Matching (KMP)
Find patterns in text in O(n + m) time by precomputing where to resume after a mismatch. Never re-check characters you've already matched.