Blog
Guides on algorithm patterns and step-by-step LeetCode problem breakdowns.
XOR Cancellation: How Pairs Disappear Like Magic
easyUnderstanding XOR from the ground up. How the cancellation property solves Single Number in O(n) time and O(1) space.
Search in Rotated Sorted Array: Modified Binary Search
mediumHow to solve LeetCode Search in Rotated Sorted Array in O(log n). Identify the sorted half and search smartly.
Remove Nth Node From End: Two Pointer Gap Technique
mediumHow to solve LeetCode Remove Nth Node From End in one pass using the two-pointer gap technique.
Longest Increasing Subsequence: DP and Binary Search
mediumHow to solve LeetCode LIS in O(n^2) with DP or O(n log n) with patience sorting. Both approaches explained.
Letter Combinations of a Phone Number: Backtracking
mediumHow to solve LeetCode Letter Combinations using backtracking. Build all combinations from digit-to-letter mapping.
Combination Sum: Backtracking with Reuse
mediumHow to solve LeetCode Combination Sum using backtracking with unlimited element reuse. Pruning explained visually.
Word Search: Grid Backtracking
mediumHow to solve LeetCode Word Search using DFS backtracking on a grid. The choose-explore-unchoose pattern.
Validate BST: Range Checking vs Inorder
mediumHow to solve LeetCode Validate BST with range bounds or inorder traversal. Two approaches compared.
Valid Palindrome: Two Pointer String Check
easyHow to solve LeetCode Valid Palindrome with two pointers. Handle non-alphanumeric characters cleanly.
Top K Frequent Elements: Bucket Sort Trick
mediumHow to solve LeetCode Top K Frequent Elements in O(n) with bucket sort. Faster than heap for this problem.
Subsets: Backtracking Decision Tree
mediumHow to solve LeetCode Subsets using backtracking. Generate all 2^n subsets with the include/exclude pattern.
Spiral Matrix: Layer by Layer Traversal
mediumHow to solve LeetCode Spiral Matrix with boundary tracking. The four-direction traversal pattern explained.
Serialize and Deserialize Binary Tree
hardHow to solve LeetCode Serialize/Deserialize Binary Tree with preorder DFS. Convert trees to strings and back.
Permutations: Complete Backtracking Guide
mediumHow to solve LeetCode Permutations using backtracking. Build all n! arrangements with the swap technique.
Palindromic Substrings: Expand Around Center
mediumHow to solve LeetCode Palindromic Substrings in O(n^2) using expand-from-center. Count all palindromes efficiently.
Min Stack: O(1) Minimum with Two Stacks
mediumHow to implement LeetCode Min Stack with O(1) push, pop, and getMin. The auxiliary stack trick explained.
Merge Intervals: Sort and Sweep
mediumHow to solve LeetCode Merge Intervals by sorting and merging overlapping ranges. The essential interval pattern.
Median of Two Sorted Arrays: Binary Search on Partitions
hardHow to solve LeetCode Median of Two Sorted Arrays in O(log(min(m,n))). The hardest binary search problem explained.
LRU Cache: Hash Map + Doubly Linked List
mediumHow to implement LeetCode LRU Cache with O(1) get and put. The classic design problem explained visually.
Lowest Common Ancestor: Post-Order Tree Logic
mediumHow to solve LeetCode Lowest Common Ancestor using post-order DFS. The elegant recursive solution explained.
Longest Palindromic Substring: Expand From Center
mediumHow to solve LeetCode Longest Palindromic Substring in O(n^2). The expand-from-center technique explained visually.
Kth Largest Element: Heap vs Quickselect
mediumHow to solve LeetCode Kth Largest Element with a min-heap or quickselect. Two O(n) approaches compared.
House Robber: DP With a Twist
mediumHow to solve LeetCode House Robber with dynamic programming. The rob-or-skip decision explained visually.
Decode Ways: DP String Decoding
mediumHow to solve LeetCode Decode Ways with dynamic programming. Handle zeros and two-digit codes step by step.
Course Schedule: Cycle Detection with DFS
mediumHow to solve LeetCode Course Schedule using topological sort and cycle detection. Graph DFS explained visually.
Coin Change: Classic Dynamic Programming
mediumHow to solve LeetCode Coin Change with bottom-up DP. Visual table walkthrough for the unbounded knapsack pattern.
Valid Anagram: Frequency Counting Pattern
easyHow to solve LeetCode Valid Anagram using character frequency counting. Sort vs hash map approaches compared.
3Sum: Sorting Plus Two Pointers
mediumHow to solve LeetCode 3Sum in O(n^2) using sort and converging pointers. Handle duplicates cleanly.
Rotate Array: The Triple Reverse Trick
mediumHow to solve LeetCode Rotate Array in O(n) time and O(1) space using three reversals.
Reverse Linked List: The Pointer Swap Technique
easyHow to solve LeetCode Reverse Linked List iteratively and recursively. Visual step-by-step pointer reversal guide.
Product of Array Except Self: Two-Pass Prefix/Suffix
mediumHow to solve LeetCode Product of Array Except Self in O(n) without division. Prefix and suffix product walkthrough.
Number of Islands: Grid DFS Pattern
mediumHow to solve LeetCode Number of Islands using DFS flood fill. The essential grid traversal pattern explained.
Minimum Window Substring: Advanced Sliding Window
hardHow to solve LeetCode Minimum Window Substring with sliding window and frequency counting. O(n) solution.
Merge Sorted Array: The Backwards Trick
easyHow to solve LeetCode Merge Sorted Array in-place by filling from the end. O(n) two-pointer solution explained.
Maximum Depth of Binary Tree: Recursion Made Simple
easyHow to solve LeetCode Maximum Depth of Binary Tree with DFS recursion. Visual tree traversal walkthrough.
Majority Element: Boyer-Moore Voting Algorithm
easyHow to solve LeetCode Majority Element in O(n) time and O(1) space with the Boyer-Moore voting algorithm.
Longest Substring Without Repeating Characters
mediumHow to solve LeetCode Longest Substring Without Repeating Characters using sliding window and a set. O(n) solution.
Longest Consecutive Sequence: The Set Trick
mediumHow to solve LeetCode Longest Consecutive Sequence in O(n) using a set. Why sorting is not needed.
Linked List Cycle: Floyd's Tortoise and Hare
easyHow to detect a cycle in a linked list using O(1) space. Floyd's algorithm explained with visuals.
Jump Game: Greedy Reachability
mediumHow to solve LeetCode Jump Game in O(n) using greedy farthest-reach tracking. No DP needed.
Invert Binary Tree: The Famous Three-Line Solution
easyHow to solve LeetCode Invert Binary Tree with recursion. The problem that started a meme.
Group Anagrams: Hash Map Grouping Pattern
mediumHow to solve LeetCode Group Anagrams in O(n*k) using sorted keys. Step-by-step visual walkthrough.
Daily Temperatures: Monotonic Stack Explained
mediumHow to solve LeetCode Daily Temperatures using a monotonic stack. Visual walkthrough of the next-greater-element pattern.
Container With Most Water: Two Pointer Greedy
mediumHow to solve LeetCode Container With Most Water in O(n) using two pointers. Why moving the shorter side is optimal.
Climbing Stairs: Your First Dynamic Programming Problem
easyHow to solve LeetCode Climbing Stairs with DP in O(n) time and O(1) space. The perfect intro to dynamic programming.
Binary Search (LeetCode 704): The Foundation
easyHow to implement binary search correctly. Avoid off-by-one errors with this clear visual walkthrough.
Valid Parentheses: Stack Pattern Explained
easyHow to solve LeetCode Valid Parentheses using a stack. Visual step-by-step walkthrough with Python code.
Two Sum: The Classic Interview Starter
easyHow to solve LeetCode Two Sum in O(n) using a hash map complement lookup. Step-by-step walkthrough with visuals.
Trapping Rain Water: Two Pointer Approach
hardHow to solve LeetCode Trapping Rain Water in O(n) time and O(1) space using two pointers. Visual step-by-step guide.
Contains Duplicate: Three Solutions Compared
easyHow to solve LeetCode Contains Duplicate using a set, sorting, or brute force. O(n) optimal solution explained.
Best Time to Buy and Sell Stock: One Pass Solution
easyHow to solve LeetCode Best Time to Buy and Sell Stock in O(n) by tracking the running minimum. Visual walkthrough.
Binary Search: More Than Finding a Number
Learn binary search with visual walkthroughs, Python code, and the 'search on the answer space' variant that unlocks a whole class of interview problems.
Stack Patterns: Matching, Nesting, and More
Master stack patterns for coding interviews: bracket matching, monotonic stacks, and state save/restore. Visual walkthroughs with Python examples.
Hash Map Patterns for Coding Interviews
Master the three core hash map patterns for coding interviews: frequency counting, complement lookup, and grouping. Python examples with O(1) lookups.
The Two Pointers Pattern: A Complete Guide
Master the two pointers technique for sorted array and linked list problems in O(n) time. Visual walkthrough with Python code and common variations.
The Sliding Window Pattern: A Complete Guide
Learn the sliding window technique for solving subarray and substring problems in O(n) time. Step-by-step visual walkthrough with Python code examples.