Skip to content

Blog

Guides on algorithm patterns and step-by-step LeetCode problem breakdowns.

Successful Pairs of Spells and Potions: Binary Search on Sorted Array

medium

How to solve LeetCode 2300 Successful Pairs of Spells and Potions using sorting and binary search. O((m+n) log n) solution explained with visual walkthrough.

5 min
arraysbinary-search

Removing Stars From a String: Stack Simulation

medium

How to solve LeetCode 2390 Removing Stars From a String using a stack. O(n) time, O(n) space solution explained with visual walkthrough.

5 min
stringsstacks

Maximum Twin Sum of a Linked List: Reverse and Compare

medium

How to solve LeetCode 2130 Maximum Twin Sum of a Linked List by reversing the second half. O(n) time, O(1) space solution with visual walkthrough.

5 min
linked-liststwo-pointers

Find the Difference of Two Arrays: Set Operations

easy

How to solve LeetCode 2215 Find the Difference of Two Arrays using set difference. O(n + m) time solution explained with visual walkthrough.

5 min
arrayshash-map

Delete the Middle Node of a Linked List: Fast and Slow Pointers

medium

How to solve LeetCode 2095 Delete the Middle Node of a Linked List using the fast and slow pointer technique. O(n) time, O(1) space solution explained with visual walkthrough.

5 min
linked-liststwo-pointers

Three Divisors: Spotting Squares of Primes

easy

How to solve LeetCode 1952 Three Divisors. A number has exactly three positive divisors only when it is the square of a prime.

4 min
math

The Number of Weak Characters in the Game: Sorting Trick

medium

How to solve LeetCode 1996 The Number of Weak Characters. Sort by attack descending and defense ascending to find weak characters in one pass.

5 min
arrayssorting

The Number of the Smallest Unoccupied Chair

medium

How to solve LeetCode 1942 The Number of the Smallest Unoccupied Chair. Use two heaps to simulate chair assignment and find the target friend's seat.

5 min
arraysheap

The Number of Good Subsets: Bitmask DP Over Primes

hard

How to solve LeetCode 1994 The Number of Good Subsets. Bitmask DP using prime factorization to count subsets with square-free products.

6 min
arraysmath

Sum of Digits of String After Convert: Letter-to-Number Simulation

easy

How to solve LeetCode 1945 Sum of Digits of String After Convert. Convert each character to its alphabet position, concatenate, then repeatedly sum digits.

4 min
stringssimulation

Reverse Prefix of Word: Find and Flip

easy

How to solve LeetCode 2000 Reverse Prefix of Word. Find the first occurrence of a character, reverse the prefix up to that index, and return the modified string.

5 min
stringstwo-pointers

Remove Stones to Minimize the Total

medium

How to solve LeetCode 1962 using a max-heap to greedily halve the largest pile. Visual heap walkthrough with step-by-step operations.

5 min
arraysheap

Operations on Tree: Lock, Unlock, and Upgrade

medium

How to solve LeetCode 1993 Operations on Tree. Design a locking tree with parent traversal and DFS for upgrade operations.

6 min
treesdesign

Number of Ways to Separate Numbers: DP with LCP Optimization

hard

How to solve LeetCode 1977 Number of Ways to Separate Numbers using dynamic programming with longest common prefix optimization.

8 min
stringsdynamic-programming

Number of Ways to Arrive at Destination: Dijkstra with Path Counting

medium

How to solve LeetCode 1976 Number of Ways to Arrive at Destination using modified Dijkstra's algorithm with path counting.

8 min
graphsdynamic-programming

Number of Visible People in a Queue: Monotonic Stack

hard

How to solve LeetCode 1944 Number of Visible People in a Queue. Use a monotonic stack to count visible people from each position in O(n) time.

7 min
arraysstacks

Number of Unique Good Subsequences: DP Without Leading Zeros

hard

How to solve LeetCode 1987 Number of Unique Good Subsequences with dynamic programming. Track subsequences ending in 0 and 1 separately to avoid leading zeros.

7 min
stringsdynamic-programming

Number of Strings That Appear as Substrings in Word

easy

How to solve LeetCode 1967 by checking each pattern against the target word. Visual walkthrough of the substring matching approach.

4 min
strings

Minimum Total Space Wasted With K Resizing Operations

medium

How to solve LeetCode 1959 using interval DP. Visual walkthrough of partitioning an array to minimize wasted space with limited resizes.

6 min
dynamic-programmingarrays

Minimum Time to Type Word Using Special Typewriter: Greedy Circular Distance

easy

How to solve LeetCode 1974 Minimum Time to Type Word Using Special Typewriter. Greedy approach with circular distance calculation.

5 min
stringsgreedy

Minimum Number of Work Sessions to Finish the Tasks

medium

How to solve LeetCode 1986 with bitmask DP. Track completed tasks as a bitmask and greedily pack them into sessions.

7 min
dynamic-programmingbit-manipulation

Minimum Number of Swaps to Make the String Balanced

medium

How to solve LeetCode 1963 with a greedy bracket-counting approach. Visual walkthrough of tracking unmatched brackets and computing minimum swaps.

5 min
stringsstacks

Minimum Non-Zero Product of the Array Elements

medium

How to solve LeetCode 1969 using greedy bit manipulation and modular exponentiation. Visual walkthrough of minimizing the product of array elements.

5 min
mathgreedy

Minimum Garden Perimeter to Collect Enough Apples: Binary Search on Math

medium

How to solve LeetCode 1954 Minimum Garden Perimeter to Collect Enough Apples using binary search on a closed-form formula.

8 min
mathbinary-search

Minimum Difference Between Highest and Lowest of K Scores

easy

How to solve LeetCode 1984. Sort the array and slide a window of size k to find the minimum difference between the largest and smallest in any group of k.

3 min
arrayssorting

Minimize the Difference Between Target and Chosen Elements

medium

How to solve LeetCode 1981. Use row-by-row DP to track all achievable sums, then find the one closest to the target.

6 min
arraysdynamic-programming

Maximum Product of the Length of Two Palindromic Substrings

hard

How to solve LeetCode 1960 using Manacher's algorithm with prefix and suffix maximums. Visual breakdown of finding optimal non-overlapping palindromes.

8 min
strings

Maximum Number of Weeks for Which You Can Work: Greedy Scheduling

medium

How to solve LeetCode 1953 Maximum Number of Weeks for Which You Can Work. Find the max weeks you can work by balancing projects with a greedy approach.

8 min
arraysgreedy

Maximum Matrix Sum: Greedy with Negative Count

medium

How to solve LeetCode 1975 Maximum Matrix Sum. Greedy approach counting negatives and finding minimum absolute value.

7 min
matrixgreedy

Maximum Genetic Difference Query: Trie + DFS

hard

How to solve LeetCode 1938 Maximum Genetic Difference Query. Combine a bitwise trie with DFS traversal to answer XOR queries efficiently.

8 min
triebit-manipulation

Maximum Compatibility Score Sum: Optimal Assignment with Backtracking

medium

How to solve LeetCode 1947 Maximum Compatibility Score Sum using backtracking over permutations and bitmask DP.

5 min
arraysbacktracking

Last Day Where You Can Still Cross

hard

How to solve LeetCode 1970 using reverse union-find on a flooding grid. Visual walkthrough of binary search plus BFS and the reverse-time union-find approach.

8 min
matrixbinary-search

Largest Number After Mutating Substring: Greedy Digit Replacement

medium

How to solve LeetCode 1946 Largest Number After Mutating Substring with a greedy scan. Replace a contiguous substring of digits to maximize the number.

5 min
stringsgreedy

GCD Sort of an Array: Union-Find with Prime Factorization

hard

How to solve LeetCode 1998 GCD Sort of an Array. Use prime factorization and union-find to determine if an array can be sorted by swapping elements that share a common factor greater than 1.

6 min
arraysmath

First Day Where You Have Been in All the Rooms: DP with Modular Arithmetic

medium

How to solve LeetCode 1997 First Day Where You Have Been in All the Rooms. Derive the DP recurrence for tracking first visits with odd/even visit rules.

6 min
arraysdynamic-programming

Find Unique Binary String: Cantor's Diagonal Trick

medium

How to solve LeetCode 1980 Find Unique Binary String. Use Cantor's diagonalization to build a binary string guaranteed to differ from every string in the input.

4 min
stringsbacktracking

Find the Middle Index in Array: Prefix Sum in One Pass

easy

How to solve LeetCode 1991 Find the Middle Index in Array using a running prefix sum. O(n) solution explained with visual walkthrough.

6 min
arrays

Find the Longest Valid Obstacle Course at Each Position

hard

How to solve LeetCode 1964 using patience sorting with binary search. Visual walkthrough of the longest non-decreasing subsequence approach.

5 min
arraysbinary-search

Find the Kth Largest Integer in the Array

medium

How to solve LeetCode 1985 Find the Kth Largest Integer in the Array. Custom string comparison for large numbers explained step by step.

5 min
arraysstrings

Find if Path Exists in Graph: BFS, DFS, and Union-Find

easy

How to solve LeetCode 1971 Find if Path Exists in Graph using BFS, DFS, and Union-Find. Check graph connectivity in O(n + e).

8 min
graphsunion-find

Find Greatest Common Divisor of Array: Min, Max, and Euclid

easy

How to solve LeetCode 1979 Find Greatest Common Divisor of Array. Find the min and max of the array, then compute their GCD with the Euclidean algorithm.

5 min
arraysmath

Find Array Given Subset Sums: Divide and Reconstruct

hard

How to solve LeetCode 1982 Find Array Given Subset Sums. Sort the subset sums and repeatedly extract one element at a time using a multiset splitting technique.

6 min
arraysdivide-and-conquer

Find All Groups of Farmland: Rectangle Scanning Pattern

medium

How to solve LeetCode 1992 Find All Groups of Farmland by scanning for top-left corners and expanding to find bottom-right corners. A clean matrix traversal approach.

7 min
matrixgraph

Describe the Painting: Sweep Line on Segments

medium

How to solve LeetCode 1943 Describe the Painting. Use a sweep line with a difference array to merge overlapping color segments efficiently.

6 min
arrayssorting

Delete Duplicate Folders in System: Trie Serialization and Hash-Based Dedup

hard

How to solve LeetCode 1948 Delete Duplicate Folders in System using trie construction, subtree serialization, and hash map deduplication.

6 min
triehash-map

Delete Characters to Make Fancy String: Greedy Filtering

easy

How to solve LeetCode 1957 Delete Characters to Make Fancy String by greedily filtering out characters that would create three consecutive duplicates.

5 min
strings

Count Special Quadruplets: From Brute Force to Hash Map

easy

How to solve LeetCode 1995 Count Special Quadruplets. Reduce O(n^4) brute force to O(n^2) with a hash map trick.

6 min
arrayshash-map

Count Number of Special Subsequences: Phase-Based DP

hard

How to solve LeetCode 1955 Count Number of Special Subsequences using a three-state DP that tracks subsequence phases.

7 min
arraysdynamic-programming

Check If String Is a Prefix of Array

easy

How to solve LeetCode 1961 by incrementally concatenating array elements. A clean string matching exercise with early termination.

4 min
arraysstrings

Check if Move is Legal: Directional Grid Search

medium

How to solve LeetCode 1958 Check if Move is Legal by searching all 8 directions for a valid Othello line on the board.

7 min
matrixsimulation

Check if All Characters Have Equal Number of Occurrences

easy

How to solve LeetCode 1941 Check if All Characters Have Equal Number of Occurrences. Count character frequencies with a hash map and check if all counts are equal.

4 min
stringshash-map

Array With Elements Not Equal to Average of Neighbors

medium

How to solve LeetCode 1968 using a sorting-based wiggle arrangement. Visual walkthrough of the greedy interleaving approach.

4 min
arrayssorting

Unique Length-3 Palindromic Subsequences: First and Last Occurrence

medium

How to solve LeetCode 1930 Unique Length-3 Palindromic Subsequences by finding first and last occurrences and counting distinct middle characters.

5 min
stringshash-map

The Number of Full Rounds You Have Played: Time Interval Math

medium

How to solve LeetCode 1904 The Number of Full Rounds You Have Played. Step-by-step walkthrough with visuals.

5 min
stringsmath

Earliest and Latest Rounds Where Players Compete: Tournament Simulation

hard

How to solve LeetCode 1900 The Earliest and Latest Rounds Where Players Compete. Step-by-step walkthrough with visuals.

5 min
dynamic-programming

Sum of Floored Pairs

hard

How to solve LeetCode 1862 using prefix sums and harmonic series counting. An efficient approach that avoids brute-force pair enumeration.

5 min
arraysmath

Sum of All Subset XOR Totals

easy

How to solve LeetCode 1863 using a bit-contribution insight that reduces subset enumeration to a single OR and a left shift.

5 min
arraysbit-manipulation

Sum Game: Game Theory with Greedy Analysis

medium

How to solve LeetCode 1927 Sum Game with game theory. Visual walkthrough of optimal play between Alice and Bob.

6 min
mathgreedy

Substrings of Size Three with Distinct Characters

easy

How to solve LeetCode 1876 by sliding a fixed-size window and checking for distinct characters. A clean intro to sliding windows.

5 min
stringssliding-window

Stone Game VIII: Prefix Sums Meet Game Theory

hard

How to solve LeetCode 1872 Stone Game VIII by reducing the game to a prefix sum DP. The elegant simplification behind a hard problem.

6 min
dynamic-programmingarrays

Sorting the Sentence

easy

How to solve LeetCode 1859 by extracting position numbers from shuffled words. A clean string manipulation exercise.

4 min
stringssorting

Rotating the Box

medium

How to solve LeetCode 1861 by simulating gravity and rotating a matrix. A two-step approach combining physics simulation with matrix rotation.

6 min
matrixtwo-pointers

Remove One Element to Make the Array Strictly Increasing

easy

How to solve LeetCode 1909 by finding violation points and testing one removal. A clean single-pass approach with visual walkthrough.

5 min
arrays

Remove All Occurrences of a Substring: Stack-Based String Processing

medium

How to solve LeetCode 1910 by building a result string character by character and checking for the pattern at each step. Visual walkthrough of the stack approach.

5 min
strings

Reduction Operations to Make the Array Elements Equal

medium

How to solve LeetCode 1887 Reduction Operations to Make the Array Elements Equal by sorting and counting distinct value levels.

7 min
arrayssorting

Redistribute Characters to Make All Strings Equal: Frequency Divisibility Check

easy

How to solve LeetCode 1897 Redistribute Characters to Make All Strings Equal. Step-by-step walkthrough with visuals.

3 min
stringshash-map

Process Tasks Using Servers

medium

How to solve LeetCode 1882 Process Tasks Using Servers. Use two heaps to efficiently track free and busy servers, assigning tasks by weight priority.

6 min
arraysheap

Painting a Grid With Three Different Colors: Column-State DP

hard

How to solve LeetCode 1931 Painting a Grid With Three Different Colors using column-state dynamic programming to count valid colorings.

6 min
dynamic-programming

Number of Wonderful Substrings: Bitmask Parity Tracking

medium

How to solve LeetCode 1915 Number of Wonderful Substrings using bitmask XOR parity and prefix counting. Visual walkthrough with Python solution.

5 min
stringsbit-manipulation

Number of Ways to Rearrange Sticks With K Sticks Visible

hard

How to solve LeetCode 1866 using dynamic programming and the connection to unsigned Stirling numbers of the first kind.

6 min
mathdynamic-programming

Nearest Exit from Entrance in Maze: BFS Shortest Path

medium

How to solve LeetCode 1926 Nearest Exit from Entrance in Maze using BFS. Visual grid walkthrough for the shortest path in a matrix.

6 min
matrixgraph

Minimum XOR Sum of Two Arrays

hard

How to solve LeetCode 1879 Minimum XOR Sum of Two Arrays. Use bitmask dynamic programming to find the optimal pairing that minimizes the total XOR sum.

5 min
arraysdynamic-programming

Minimum Speed to Arrive on Time: Binary Search on the Answer

medium

How to solve LeetCode 1870 Minimum Speed to Arrive on Time using binary search on the answer space. Search speeds, not arrays.

8 min
binary-searcharrays

Minimum Space Wasted From Packaging: Binary Search with Prefix Sums

hard

How to solve LeetCode 1889 Minimum Space Wasted From Packaging using sorted arrays, binary search, and prefix sums to minimize total waste.

8 min
arraysbinary-search

Minimum Skips to Arrive at Meeting On Time: DP on Skips

hard

How to solve LeetCode 1883 Minimum Skips to Arrive at Meeting On Time with dynamic programming. Track minimum travel time for each skip count.

8 min
arraysdynamic-programming

Minimum Number of Swaps to Make the Binary String Alternating

medium

How to solve LeetCode 1864 Minimum Number of Swaps to Make the Binary String Alternating using a greedy counting approach with two target patterns.

5 min
stringsgreedy

Minimum Number of Flips to Make the Binary String Alternating

medium

How to solve LeetCode 1888 Minimum Number of Flips to Make the Binary String Alternating using string doubling and a sliding window to check all rotations efficiently.

8 min
stringsdynamic-programming

Minimum Cost to Reach Destination in Time: DP on Graphs

hard

How to solve LeetCode 1928 Minimum Cost to Reach Destination in Time using dynamic programming with a time constraint on a weighted graph.

6 min
graphdynamic-programming

Minimum Cost to Change the Final Value of Expression: Stack DP on Boolean Expressions

hard

How to solve LeetCode 1896 Minimum Cost to Change the Final Value of Expression. Step-by-step walkthrough with visuals.

8 min
stringsstacks

Minimum Absolute Difference Queries: Prefix Counts on Small Domains

medium

How to solve LeetCode 1906 using prefix frequency arrays. Visual walkthrough of answering range queries with O(1) value lookups.

4 min
arrayshash-map

Minimize Maximum Pair Sum in Array: Sort and Pair

medium

How to solve LeetCode 1877 Minimize Maximum Pair Sum by sorting and pairing extremes. A greedy two-pointer approach.

6 min
arrayssorting

Merge Triplets to Form Target Triplet: Greedy Filtering

medium

How to solve LeetCode 1899 Merge Triplets to Form Target Triplet. Step-by-step walkthrough with visuals.

5 min
arraysgreedy

Merge BSTs to Create Single BST: Grafting Trees Together

hard

How to solve LeetCode 1932 Merge BSTs to Create Single BST by matching leaf nodes to roots and validating the merged BST.

6 min
treeshash-map

Maximum Value after Insertion

medium

How to solve LeetCode 1881 Maximum Value after Insertion. Use a greedy scan to find the optimal position to insert a digit into a number string.

6 min
stringsgreedy

Maximum Product Difference Between Two Pairs

easy

How to solve LeetCode 1913 Maximum Product Difference Between Two Pairs. One-pass solution with visuals and complexity analysis.

4 min
arrayssorting

Maximum Number of Words You Can Type: Set Lookup

easy

How to solve LeetCode 1935 Maximum Number of Words You Can Type using a set of broken letters and simple word filtering.

4 min
stringshash-map

Maximum Number of Removable Characters: Binary Search on the Answer

medium

How to solve LeetCode 1898 Maximum Number of Removable Characters. Step-by-step walkthrough with visuals.

5 min
stringsbinary-search

Maximum Number of Points with Cost: Left-Right DP Sweep

medium

How to solve LeetCode 1937 Maximum Number of Points with Cost using a left-right sweep optimization that reduces O(m*n^2) DP to O(m*n).

5 min
arraysdynamic-programming

Maximum Alternating Subsequence Sum: Two-State DP

medium

How to solve LeetCode 1911 with a two-variable DP tracking even and odd positions. Visual walkthrough of the state transition pattern.

6 min
arraysdynamic-programming

Longest Common Subpath: Binary Search with Rolling Hash

hard

How to solve LeetCode 1923 Longest Common Subpath using binary search on the answer length with rolling hash. A hard problem that combines two classic techniques into one clean solution.

7 min
arraysbinary-search

Longer Contiguous Segments of Ones than Zeros

easy

How to solve LeetCode 1869 Longer Contiguous Segments of Ones than Zeros with a single pass, tracking run lengths for both digits.

5 min
strings

Largest Odd Number in String: Right-to-Left Scan

easy

How to solve LeetCode 1903 Largest Odd Number in String. Step-by-step walkthrough with visuals.

4 min
stringsgreedy

Largest Magic Square: Prefix Sums on a Matrix

medium

How to solve LeetCode 1895 Largest Magic Square. Step-by-step walkthrough with visuals.

5 min
matrix

Largest Color Value in a Directed Graph

hard

How to solve LeetCode 1857 using topological sort and dynamic programming. Visual walkthrough of tracking color frequencies along directed paths.

7 min
graphdynamic-programming

Jump Game VII: BFS with a Sliding Window

medium

How to solve LeetCode 1871 Jump Game VII efficiently using BFS with a pointer optimization. Avoid the TLE trap.

7 min
dynamic-programmingstrings

Incremental Memory Leak

medium

How to solve LeetCode 1860 by simulating memory allocation second by second. A clean simulation problem with a mathematical shortcut.

4 min
simulation

Get Biggest Three Rhombus Sums in a Grid

medium

How to solve LeetCode 1878 Get Biggest Three Rhombus Sums in a Grid. Enumerate all possible rhombuses by center and size, compute border sums, and track the top three distinct values.

6 min
matrixsorting

Finding Pairs With a Certain Sum

medium

How to solve LeetCode 1865 Finding Pairs With a Certain Sum using a frequency map for efficient pair counting across two arrays.

5 min
arraysdesign

Find the Student that Will Replace the Chalk: Prefix Sum Meets Binary Search

medium

How to solve LeetCode 1894 by combining prefix sums, modulo arithmetic, and binary search. Step-by-step walkthrough with visuals.

6 min
arraysbinary-search

Eliminate Maximum Number of Monsters: Greedy with Sorted Arrival Times

medium

How to solve LeetCode 1921 Eliminate Maximum Number of Monsters using greedy sorting. Compute arrival times, sort, and fire at the closest monster each minute.

6 min
arrayssorting

Determine Whether Matrix Can Be Obtained By Rotation

easy

How to solve LeetCode 1886 Determine Whether Matrix Can Be Obtained By Rotation by checking all four 90-degree rotations against the target.

6 min
matrix

Design Movie Rental System: Sorted Containers Meet Heaps

hard

How to solve LeetCode 1912 Design Movie Rental System using sorted sets and heaps. Step-by-step data structure walkthrough with visuals.

6 min
designheap

Cyclically Rotating a Grid: Layer-by-Layer Simulation

medium

How to solve LeetCode 1914 Cyclically Rotating a Grid by extracting layers and rotating elements. Visual walkthrough with Python solution.

6 min
matrixsimulation

Count Ways to Build Rooms in an Ant Colony: Tree Combinatorics

hard

How to solve LeetCode 1916 Count Ways to Build Rooms in an Ant Colony using DFS, factorials, and modular inverse. Visual tree walkthrough with Python solution.

6 min
treesmath

Count Sub Islands: Grid DFS with Cross-Reference

medium

How to solve LeetCode 1905 Count Sub Islands using DFS to validate islands across two grids. Visual walkthrough of the cross-reference pattern.

5 min
matrixgraph

Count Square Sum Triples: Enumerating Pythagorean Triples

easy

How to solve LeetCode 1925 Count Square Sum Triples by iterating over all pairs and checking for perfect squares. Full walkthrough with visuals.

4 min
math

Count Good Numbers: Modular Exponentiation

medium

How to solve LeetCode 1922 Count Good Numbers using modular exponentiation. Count valid digit strings of length n in O(log n) time with binary exponentiation.

5 min
math

Concatenation of Array: Simple Array Construction

easy

How to solve LeetCode 1929 Concatenation of Array. Visual walkthrough of array duplication and index mapping.

4 min
arrays

Check if Word Equals Summation of Two Words

easy

How to solve LeetCode 1880 Check if Word Equals Summation of Two Words. Map each letter to a digit, form numbers by concatenation, and compare the sum.

4 min
strings

Check if All the Integers in a Range Are Covered: Boolean Array Marking

easy

How to solve LeetCode 1893 by marking covered integers in a boolean array. Step-by-step walkthrough with visuals.

5 min
arrayshash-map

Build Array from Permutation: Double Indexing in One Pass

easy

How to solve LeetCode 1920 Build Array from Permutation by applying the formula ans[i] = nums[nums[i]]. A clean introduction to permutation-based array construction.

5 min
arrayssimulation

Add Minimum Number of Rungs: Greedy Gap Filling

medium

How to solve LeetCode 1936 Add Minimum Number of Rungs with a greedy single-pass approach that fills gaps exceeding the max climb distance.

5 min
arraysgreedy

Truncate Sentence: Split, Slice, and Join

easy

How to solve LeetCode 1816 Truncate Sentence. Split the sentence into words, take the first k, and join them back together.

4 min
strings

Sum of Digits in Base K

easy

How to solve LeetCode 1837 Sum of Digits in Base K using repeated division. A clean math pattern for base conversion.

4 min
math

Sum of Beauty of All Substrings

medium

How to solve LeetCode 1781 Sum of Beauty of All Substrings using frequency counting. Enumerate substrings and track character frequencies incrementally.

6 min
stringshash-map

Splitting a String Into Descending Consecutive Values: Backtracking

medium

How to solve LeetCode 1849 Splitting a String Into Descending Consecutive Values using backtracking. Try each split point and recursively validate the descending sequence.

7 min
stringsbacktracking

Single-Threaded CPU

medium

How to solve LeetCode 1834 Single-Threaded CPU using sorting and a min-heap. A simulation problem explained with visual walkthroughs.

6 min
arrayssorting

Sign of the Product of an Array: Count Negatives

easy

How to solve LeetCode 1822 Sign of the Product of an Array. Count negatives and check for zeros to determine the product sign without computing the actual product.

3 min
arraysmath

Sentence Similarity III: Two-Pointer Word Matching

medium

How to solve LeetCode 1813 Sentence Similarity III. Use two pointers to match words from both ends and check if one sentence can be formed by inserting words into the other.

5 min
stringstwo-pointers

Second Largest Digit in a String: Single-Pass Tracking

easy

How to solve LeetCode 1796 Second Largest Digit in a String with a single pass. Clean Python solution with visual walkthrough.

5 min
stringshash-map

Seat Reservation Manager: Min-Heap Design Pattern

medium

How to solve LeetCode 1845 Seat Reservation Manager using a min-heap. The design pattern for always fetching the smallest available element.

5 min
designheap

Replace All Digits with Characters

easy

How to solve LeetCode 1844 Replace All Digits with Characters. Apply the shift operation to transform digit characters based on their preceding letter.

4 min
strings

Queries on Number of Points Inside a Circle: Distance Check Pattern

medium

How to solve LeetCode 1828 Queries on Number of Points Inside a Circle. Check each point against each query circle using squared distance.

5 min
arraysmath

Number of Restricted Paths From First to Last Node: Dijkstra + DP Pattern

medium

How to solve LeetCode 1786 Number of Restricted Paths From First to Last Node using Dijkstra and dynamic programming. The shortest-path DP counting pattern explained with visual walkthroughs.

6 min
graphdynamic-programming

Number of Orders in the Backlog: Dual Heap Simulation

medium

How to solve LeetCode 1801 with a max-heap for buys and a min-heap for sells. Simulate an order book by matching and accumulating.

6 min
arraysheap

Number of Different Subsequences GCDs: Enumerate Candidate GCDs

hard

How to solve LeetCode 1819 Number of Different Subsequences GCDs. For each candidate GCD value g, check if g is achievable by computing the GCD of all multiples of g present in the array.

4 min
arraysmath

Number of Different Integers in a String: Parsing and Sets

easy

How to solve LeetCode 1805 Number of Different Integers in a String by extracting integers and counting unique values with a set.

5 min
stringshash-map

Minimum Sideway Jumps: Lane-Switching DP Pattern

medium

How to solve LeetCode 1824 Minimum Sideway Jumps using dynamic programming. Track minimum jumps across three lanes with a greedy DP approach.

7 min
arraysdynamic-programming

Minimum Operations to Make the Array Increasing: Greedy Pass Pattern

easy

How to solve LeetCode 1827 Minimum Operations to Make the Array Increasing with a single greedy pass. Track the minimum required value as you scan.

6 min
arraysgreedy

Minimum Number of Operations to Reinitialize a Permutation

medium

How to solve LeetCode 1806 by simulating the permutation cycle or tracking a single element's orbit to find when the array returns to its original state.

5 min
arraysmath

Minimum Number of Operations to Make String Sorted

hard

How to solve LeetCode 1830 Minimum Number of Operations to Make String Sorted using factorials and modular arithmetic. A permutation ranking problem explained with visual walkthroughs.

6 min
stringsmath

Minimum Interval to Include Each Query

hard

How to solve LeetCode 1851 Minimum Interval to Include Each Query with sorting and a min-heap. Sweep through sorted queries, lazily add and expire intervals, and read the answer from the heap top.

6 min
arrayssorting

Minimum Elements to Add to Form a Given Sum: Greedy Math Pattern

medium

How to solve LeetCode 1785 Minimum Elements to Add to Form a Given Sum using greedy ceiling division. The math-based greedy pattern explained with visual walkthroughs.

6 min
arraysgreedy

Minimum Distance to the Target Element: Linear Scan

easy

How to solve LeetCode 1848 Minimum Distance to the Target Element with a single pass through the array. Track the closest matching index.

4 min
arrays

Minimum Adjacent Swaps to Reach the Kth Smallest Number

medium

How to solve LeetCode 1850 Minimum Adjacent Swaps to Reach the Kth Smallest Number using next permutation and greedy swap counting.

7 min
stringsgreedy

Minimum Absolute Sum Difference: Binary Search for Best Replacement

medium

How to solve LeetCode 1818 Minimum Absolute Sum Difference. Sort a copy of nums1, then binary search to find the best replacement for each position.

5 min
arraysbinary-search

Maximum XOR for Each Query: Prefix XOR Pattern

medium

How to solve LeetCode 1829 Maximum XOR for Each Query using prefix XOR and bit masking. Process queries in reverse with cumulative XOR.

5 min
arraysbit-manipulation

Maximum Value at a Given Index in a Bounded Array: Binary Search on Answer

medium

How to solve LeetCode 1802 by binary searching the peak value and using arithmetic series to compute the minimum array sum. A clean binary search on answer problem.

6 min
binary-searchgreedy

Maximum Subarray Min-Product: Monotonic Stack + Prefix Sums

medium

How to solve LeetCode 1856 Maximum Subarray Min-Product using a monotonic stack and prefix sums. Visual walkthrough, Python solution, and O(n) complexity analysis.

9 min
arraysstacks

Maximum Score of a Good Subarray: Two-Pointer Expansion

hard

How to solve LeetCode 1793 Maximum Score of a Good Subarray using greedy two-pointer expansion from k. Visual walkthrough included.

7 min
arraysstacks

Maximum Population Year

easy

How to solve LeetCode 1854 Maximum Population Year using a difference array and prefix sum. Find the earliest year with the highest number of people alive.

6 min
arrays

Maximum Number of Groups Getting Fresh Donuts: DP with Remainder States

hard

How to solve LeetCode 1815 Maximum Number of Groups Getting Fresh Donuts. Use dynamic programming on remainder counts to maximize the number of groups that start with fresh donuts.

7 min
dynamic-programmingbit-manipulation

Maximum Number of Consecutive Values You Can Make: Greedy Reachability

medium

How to solve LeetCode 1798 Maximum Number of Consecutive Values You Can Make using a greedy sorted-coins approach. Visual walkthrough of the reachable range expansion.

6 min
arraysgreedy

Maximum Ice Cream Bars

medium

How to solve LeetCode 1833 Maximum Ice Cream Bars using a greedy sorting approach. Buy the cheapest items first to maximize count.

6 min
arrayssorting

Maximum Element After Decreasing and Rearranging: Sort and Greedy

medium

How to solve LeetCode 1846 Maximum Element After Decreasing and Rearranging using sorting and greedy adjustment. Build the largest valid sequence step by step.

5 min
arrayssorting

Maximum Distance Between a Pair of Values: Two Pointer Sweep

medium

How to solve LeetCode 1855 Maximum Distance Between a Pair of Values using two pointers on non-increasing arrays. O(n + m) time, O(1) space.

6 min
arraystwo-pointers

Maximum Building Height

hard

How to solve LeetCode 1840 Maximum Building Height. Propagate height restrictions in both directions, then find the peak between consecutive restricted buildings.

7 min
arraysmath

Maximum Average Pass Ratio: Greedy Heap Pattern

medium

How to solve LeetCode 1792 Maximum Average Pass Ratio using a max heap and greedy allocation. Visual walkthrough included.

6 min
arraysheap

Maximum Ascending Subarray Sum: Greedy Scan Pattern

easy

How to solve LeetCode 1800 Maximum Ascending Subarray Sum in O(n) with a single pass. Track the current ascending run and reset when the sequence breaks.

5 min
arrays

Maximize Score After N Operations: Bitmask DP Pattern

hard

How to solve LeetCode 1799 Maximize Score After N Operations using bitmask dynamic programming. The bitmask DP pattern explained with visual walkthroughs.

7 min
arraysdynamic-programming

Maximize Number of Nice Divisors: The Power of 3s

hard

How to solve LeetCode 1808 Maximize Number of Nice Divisors using the mathematical insight that splitting into 3s maximizes the product, with modular exponentiation.

5 min
math

Make the XOR of All Segments Equal to Zero: DP + Bit Manipulation Pattern

hard

How to solve LeetCode 1787 Make the XOR of All Segments Equal to Zero using dynamic programming and XOR properties. The grouped DP with bit manipulation pattern explained with visual walkthroughs.

7 min
arraysdynamic-programming

Longest Substring Of All Vowels in Order

medium

How to solve LeetCode 1839 Longest Substring Of All Vowels in Order. Track groups of consecutive vowels and check for the beautiful substring pattern.

6 min
stringssliding-window

Frequency of the Most Frequent Element

medium

How to solve LeetCode 1838 Frequency of the Most Frequent Element using sorting and sliding window. Track the cost to equalize a window of elements.

5 min
arraysbinary-search

Finding the Users Active Minutes: Hash Map Counting

medium

How to solve LeetCode 1817 Finding the Users Active Minutes. Use a hash map of sets to collect unique minutes per user, then build a frequency array.

5 min
arrayshash-map

Finding MK Average: Sorted Window Design Pattern

hard

How to solve LeetCode 1825 Finding MK Average using sorted containers and running sums. A data structure design problem with trimmed means.

6 min
designheap

Find XOR Sum of All Pairs Bitwise AND

hard

How to solve LeetCode 1835 Find XOR Sum of All Pairs Bitwise AND using bit manipulation properties. A math-heavy problem explained with visual walkthroughs.

5 min
arraysbit-manipulation

Find the Winner of the Circular Game: The Josephus Problem

medium

How to solve LeetCode 1823 Find the Winner of the Circular Game. Use the Josephus recurrence to find the last person standing in O(n) time and O(1) space.

5 min
arraysmath

Find Nearest Point That Has the Same X or Y Coordinate

easy

How to solve LeetCode 1779 Find Nearest Point using a simple linear scan. Filter valid points and track the minimum Manhattan distance.

6 min
arrays

Find Center of Star Graph: Graph Observation Pattern

easy

How to solve LeetCode 1791 Find Center of Star Graph. A simple graph observation that appears in interviews.

5 min
graph

Evaluate the Bracket Pairs of a String: Hash Map Substitution

medium

How to solve LeetCode 1807 Evaluate the Bracket Pairs of a String using hash map lookups for bracket pair replacement.

5 min
stringshash-map

Determine Color of a Chessboard Square: Quick Math Trick

easy

How to solve LeetCode 1812 Determine Color of a Chessboard Square. Use coordinate parity to instantly determine if a square is black or white.

4 min
stringsmath

Design Authentication Manager: Hash Map Design Pattern

medium

How to solve LeetCode 1797 Design Authentication Manager using a hash map for token management. Clean Python solution with visual walkthrough.

6 min
designhash-map

Count Pairs With XOR in a Range: Trie Bit Manipulation

hard

How to solve LeetCode 1803 Count Pairs With XOR in a Range using a bitwise trie. Count valid pairs efficiently with prefix counting.

7 min
arraystrie

Count Pairs Of Nodes: Sorted Degrees and Two Pointers

hard

How to solve LeetCode 1782 Count Pairs Of Nodes using sorted degrees, two pointers, and edge correction. Answer multiple queries efficiently.

7 min
graphtwo-pointers

Count Nice Pairs in an Array: Hash Map with Algebraic Trick

medium

How to solve LeetCode 1814 Count Nice Pairs in an Array. Rearrange the equation to group elements by their difference with their reverse, then count pairs with a hash map.

6 min
arrayshash-map

Closest Room: Offline Queries with Sorted Set

hard

How to solve LeetCode 1847 Closest Room using offline query processing with sorting and binary search. The pattern for handling range-filtered nearest-neighbor queries.

5 min
arraysbinary-search

Check if the Sentence Is Pangram

easy

How to solve LeetCode 1832 Check if the Sentence Is Pangram using a set. A simple string problem explained with visual walkthroughs.

5 min
stringshash-map

Check if One String Swap Can Make Strings Equal: Mismatch Counting Pattern

easy

How to solve LeetCode 1790 Check if One String Swap Can Make Strings Equal using mismatch counting. The character comparison pattern explained with visual walkthroughs.

5 min
stringshash-map

Check if Number is a Sum of Powers of Three

medium

How to solve LeetCode 1780 Check if Number is a Sum of Powers of Three using ternary representation. If every digit in base 3 is 0 or 1, the answer is true.

4 min
math

Check if Binary String Has at Most One Segment of Ones: Simple Scan Pattern

easy

How to solve LeetCode 1784 Check if Binary String Has at Most One Segment of Ones. The left-to-right scan pattern explained with visual walkthroughs.

5 min
strings

Car Fleet II: Monotone Stack Collision Times

hard

How to solve LeetCode 1776 Car Fleet II using a monotone stack. Process cars from right to left to calculate collision times efficiently.

6 min
arraysstacks

Where Will the Ball Fall: Grid Simulation

medium

How to solve LeetCode 1706 Where Will the Ball Fall. Simulate each ball column by column through the grid of diagonal boards.

5 min
matrixsimulation

Ways to Split Array Into Three Subarrays: Prefix Sums + Binary Search

medium

How to solve LeetCode 1712 Ways to Split Array Into Three Subarrays using prefix sums and binary search. Break down the two-pointer approach with visual walkthroughs.

7 min
arraysbinary-search

Tuple with Same Product: Hash Map Counting Pattern

medium

How to solve LeetCode 1726 Tuple with Same Product using hash map pair counting. The product-pair technique explained with visual walkthroughs.

5 min
arrayshash-map

Tree of Coprimes: DFS with Ancestor Tracking

hard

How to solve LeetCode 1766 Tree of Coprimes using DFS with value-indexed ancestor tracking. Find the closest coprime ancestor for each node efficiently.

8 min
treesmath

Swapping Nodes in a Linked List: Two-Pointer Technique

medium

How to solve LeetCode 1721 Swapping Nodes in a Linked List using the two-pointer technique. Find the kth node from both ends in one pass.

5 min
linked-liststwo-pointers

Sum of Unique Elements: Frequency Counting Pattern

easy

How to solve LeetCode 1748 Sum of Unique Elements using hash map frequency counting. Clean visual explanation.

5 min
arrayshash-map

Restore the Array From Adjacent Pairs

medium

How to solve LeetCode 1743 by building an adjacency map and walking the chain. A clean graph traversal problem using hash maps in O(n).

6 min
arrayshash-map

Palindrome Partitioning IV: Three-Way Palindrome Split

hard

How to solve LeetCode 1745 Palindrome Partitioning IV using palindrome DP precomputation and two-pointer splits. Clean visual explanation.

6 min
stringsdynamic-programming

Number of Ways to Reconstruct a Tree: Ancestor Pair Analysis

hard

How to solve LeetCode 1719 Number of Ways to Reconstruct a Tree using degree counting and ancestor pair validation. A hard tree problem explained with visual walkthroughs.

7 min
treesgraph

Number of Students Unable to Eat Lunch: Queue Simulation

easy

How to solve LeetCode 1700 using counting instead of simulation. Learn why counting preferences beats direct queue simulation.

6 min
arraysstacks

Number of Rectangles That Can Form the Largest Square

easy

How to solve LeetCode 1725 Number of Rectangles That Can Form the Largest Square. A clean single-pass approach explained with visual walkthroughs.

5 min
arrays

Minimum Operations to Make a Subsequence: LIS Reduction

hard

How to solve LeetCode 1713 Minimum Operations to Make a Subsequence by reducing it to Longest Increasing Subsequence with binary search.

6 min
arraysbinary-search

Minimum Number of People to Teach: Greedy Language Selection

medium

How to solve LeetCode 1733 Minimum Number of People to Teach by identifying disconnected friendships and choosing the optimal language. Hash map and greedy approach explained.

6 min
arrayshash-map

Minimum Operations to Move All Balls: Prefix Sum Pattern

medium

How to solve LeetCode 1769 Minimum Number of Operations to Move All Balls to Each Box using prefix sums. Two passes replace an O(n^2) brute force with O(n).

5 min
arraysstrings

Minimum Limit of Balls in a Bag: Binary Search on Answer Pattern

medium

How to solve LeetCode 1760 Minimum Limit of Balls in a Bag using binary search on the answer. The classic pattern of binary searching on the result when you can check feasibility.

6 min
arraysbinary-search

Minimum Length of String After Deleting Similar Ends: Two-Pointer Trim

medium

How to solve LeetCode 1750 Minimum Length of String After Deleting Similar Ends using two pointers. Clean visual explanation.

6 min
stringstwo-pointers

Minimum Degree of a Connected Trio in a Graph: Triangle Detection Pattern

hard

How to solve LeetCode 1761 Minimum Degree of a Connected Trio in a Graph using optimized triangle detection. Find all triangles and compute their external degrees.

6 min
graph

Minimum Changes To Make Alternating Binary String: Greedy Counting Pattern

easy

How to solve LeetCode 1758 Minimum Changes To Make Alternating Binary String using greedy counting. Compare against both alternating patterns and take the minimum.

4 min
strings

Minimum Adjacent Swaps for K Consecutive Ones: Sliding Window on Positions

hard

How to solve LeetCode 1703 using position extraction, median grouping, and prefix sums. The sliding window meets meeting point pattern.

6 min
arraysgreedy

Minimize Hamming Distance After Swap Operations: Union-Find Grouping

medium

How to solve LeetCode 1722 Minimize Hamming Distance After Swap Operations using Union-Find. Group connected indices and count mismatches per component.

7 min
arraysunion-find

Merge Strings Alternately: Two-Pointer Interleaving

easy

How to solve LeetCode 1768 Merge Strings Alternately using two pointers. A clean approach to interleaving characters from two strings.

6 min
stringstwo-pointers

Maximum XOR With an Element From Array: Offline Queries with a Trie

hard

How to solve LeetCode 1707 Maximum XOR With an Element From Array. Sort queries by limit, build a binary trie incrementally, and greedily maximize XOR.

5 min
arraystrie

Maximum Units on a Truck: Greedy Sorting

easy

How to solve LeetCode 1710 Maximum Units on a Truck. Sort boxes by units per box in descending order and greedily load the truck.

4 min
arrayssorting

Maximum Score From Removing Substrings: Greedy Stack Pattern

medium

How to solve LeetCode 1717 Maximum Score From Removing Substrings using a greedy two-pass stack approach. Visual walkthrough of the greedy ordering strategy.

7 min
stringsstacks

Maximum Score From Removing Stones: Greedy Math

medium

How to solve LeetCode 1753 Maximum Score From Removing Stones using a greedy math approach. The pile balancing pattern explained visually.

6 min
mathgreedy

Maximum Score from Performing Multiplication Operations: DP on Two Ends

hard

How to solve LeetCode 1770 using dynamic programming on array endpoints. A clear explanation of the interval DP pattern with visual walkthrough.

7 min
arraysdynamic-programming

Maximum Number of Events That Can Be Attended II: DP with Binary Search

hard

How to solve LeetCode 1751 Maximum Number of Events That Can Be Attended II using dynamic programming with binary search. Interval scheduling with limited attendance explained visually.

7 min
arraysdynamic-programming

Maximum Number of Balls in a Box

easy

How to solve LeetCode 1742 Maximum Number of Balls in a Box. Compute digit sums as hash keys and count frequencies to find the fullest box.

5 min
hash-mapmath

Maximum Binary String After Change: Greedy Pattern

medium

How to solve LeetCode 1702 Maximum Binary String After Change with a greedy approach. Learn why all zeros can be collected and converted.

6 min
stringsgreedy

Maximum Absolute Sum of Any Subarray: Prefix Sum Extremes

medium

How to solve LeetCode 1749 Maximum Absolute Sum of Any Subarray using prefix sum tracking. Clean visual explanation.

6 min
arraysdynamic-programming

Maximize Palindrome Length From Subsequences

hard

How to solve LeetCode 1771 by extending longest palindromic subsequence to two strings. A visual guide to the DP approach.

6 min
stringsdynamic-programming

Map of Highest Peak: Multi-Source BFS on a Grid

medium

How to solve LeetCode 1765 Map of Highest Peak using multi-source BFS. Assign heights to grid cells where adjacent cells differ by at most 1.

7 min
matrixgraph

Longest Nice Substring: Divide and Conquer Pattern

easy

How to solve LeetCode 1763 Longest Nice Substring using divide and conquer. Split at characters without both cases and recursively find the longest nice substring.

6 min
stringsdivide-and-conquer

Latest Time by Replacing Hidden Digits: Greedy Position-by-Position

easy

How to solve LeetCode 1736 Latest Time by Replacing Hidden Digits using a greedy approach. Process each digit position independently for the maximum valid time.

5 min
stringsgreedy

Largest Submatrix With Rearrangements: Sorting Heights Pattern

medium

How to solve LeetCode 1727 Largest Submatrix With Rearrangements using column height sorting. The histogram-meets-greedy approach explained with visual walkthroughs.

6 min
matrixsorting

Largest Merge of Two Strings: Greedy Suffix Comparison

medium

How to solve LeetCode 1754 Largest Merge of Two Strings using greedy suffix comparison. Building the lexicographically largest merge explained visually.

5 min
stringsgreedy

Form Array by Concatenating Subarrays: Greedy Matching Pattern

medium

How to solve LeetCode 1764 Form Array by Concatenating Subarrays of Another Array using greedy matching. Visual walkthrough and clean Python solution.

6 min
arraysgreedy

Find the Highest Altitude: Prefix Sum Basics

easy

How to solve LeetCode 1732 Find the Highest Altitude using prefix sums. A clean introduction to running totals.

5 min
arraysprefix-sum

Find Minimum Time to Finish All Jobs: Backtracking with Pruning

hard

How to solve LeetCode 1723 Find Minimum Time to Finish All Jobs using backtracking with pruning. Job scheduling optimization explained with visual walkthroughs.

7 min
arraysbacktracking

Find Kth Largest XOR Coordinate Value

medium

How to solve LeetCode 1738 using 2D prefix XOR and a heap. Learn the inclusion-exclusion principle for XOR over rectangular regions.

6 min
matrixbit-manipulation

Equal Sum Arrays With Minimum Number of Operations

medium

How to solve LeetCode 1775 using a greedy approach with counting sort. Minimize operations by always making the highest-impact change first.

6 min
arraysgreedy

Determine if String Halves Are Alike: Vowel Counting

easy

How to solve LeetCode 1704 Determine if String Halves Are Alike. Split the string, count vowels in each half, and compare.

3 min
strings

Decode XORed Permutation: XOR Properties for Recovery

medium

How to solve LeetCode 1734 Decode XORed Permutation using XOR cancellation and odd-length permutation properties. Bit manipulation approach explained.

6 min
arraysbit-manipulation

Decode XORed Array: XOR Inverse Property

easy

How to solve LeetCode 1720 Decode XORed Array using the XOR inverse property. Bit manipulation pattern explained with visual walkthroughs.

5 min
arraysbit-manipulation

Count Ways to Make Array With Product: Prime Factorization and Combinatorics

hard

How to solve LeetCode 1735 Count Ways to Make Array With Product using prime factorization and the stars and bars combinatorial technique. Math and DP approach explained.

6 min
mathdynamic-programming

Count Number of Homogenous Substrings: Group Counting Pattern

medium

How to solve LeetCode 1759 Count Number of Homogenous Substrings using group counting. Count consecutive runs and apply the triangular number formula.

5 min
stringsmath

Count Items Matching a Rule: Linear Scan Pattern

easy

How to solve LeetCode 1773 Count Items Matching a Rule with a simple linear scan. A clean introduction to filtering arrays by attribute.

5 min
arraysstrings

Count Good Meals: Hash Map with Powers of Two

medium

How to solve LeetCode 1711 Count Good Meals. Use a hash map to count pairs whose sum is a power of two.

4 min
arrayshash-map

Construct the Lexicographically Largest Valid Sequence: Backtracking

medium

How to solve LeetCode 1718 Construct the Lexicographically Largest Valid Sequence using greedy backtracking. Visual walkthrough of the placement strategy.

7 min
arraysbacktracking

Closest Subsequence Sum: Meet in the Middle

hard

How to solve LeetCode 1755 Closest Subsequence Sum using meet in the middle. Splitting the search space to find the closest sum explained visually.

7 min
arraystwo-pointers

Closest Dessert Cost: Backtracking with Pruning

medium

How to solve LeetCode 1774 Closest Dessert Cost using backtracking with early pruning. A visual guide to exploring the topping decision tree.

7 min
arraysbacktracking

Checking Existence of Edge Length Limited Paths: Offline Union-Find

hard

How to solve LeetCode 1697 using sorted queries and union-find. Learn the offline query processing pattern with visual walkthroughs.

8 min
graphunion-find

Check if Array Is Sorted and Rotated: Counting Inversions

easy

How to solve LeetCode 1752 Check if Array Is Sorted and Rotated by counting order breaks. A clean single-pass approach explained visually.

5 min
arrays

Change Minimum Characters to Satisfy One of Three Conditions

medium

How to solve LeetCode 1737 using character frequency counting. Learn the prefix sum approach to efficiently evaluate all three conditions.

7 min
stringshash-map

Cat and Mouse II: Game Theory on a Grid

hard

How to solve LeetCode 1728 Cat and Mouse II using game theory with memoization. The minimax approach on grid states explained with visual walkthroughs.

9 min
matrixdynamic-programming

Can You Eat Your Favorite Candy on Your Favorite Day: Prefix Sum Range Check

medium

How to solve LeetCode 1744 Can You Eat Your Favorite Candy on Your Favorite Day using prefix sums and range overlap. Clean visual explanation.

7 min
arraysmath

Calculate Money in Leetcode Bank: Weekly Deposit Pattern

easy

How to solve LeetCode 1716 Calculate Money in Leetcode Bank using math. The arithmetic series pattern explained with visual walkthroughs.

5 min
math

Building Boxes: Minimum Floor Boxes in a Corner Pyramid

hard

How to solve LeetCode 1739 Building Boxes using math and greedy layer-filling. Find the minimum number of boxes touching the floor by stacking in tetrahedral layers.

7 min
mathgreedy

Average Waiting Time: Greedy Simulation

medium

How to solve LeetCode 1701 Average Waiting Time by tracking chef availability. A clean simulation pattern for sequential processing.

6 min
arrayssimulation

Widest Vertical Area Between Two Points Containing No Points

easy

How to solve LeetCode 1637 Widest Vertical Area Between Two Points Containing No Points. Sort x-coordinates and find the maximum gap between consecutive values.

5 min
arrayssorting

Ways to Make a Fair Array: Prefix Sum Trick

medium

How to solve LeetCode 1664 Ways to Make a Fair Array using prefix sums. Visual walkthrough of even/odd index tracking after element removal.

7 min
arraysdynamic-programming

Sum of Absolute Differences in a Sorted Array: Prefix Sum Trick

medium

How to solve LeetCode 1685 Sum of Absolute Differences in a Sorted Array. Use prefix sums with sorted order to compute all pairwise absolute differences in linear time.

5 min
arraysmath

Stone Game VII: Dynamic Programming on Subarrays

medium

How to solve LeetCode 1690 Stone Game VII using dynamic programming. Optimal game theory with interval DP explained visually.

7 min
arraysdynamic-programming

Stone Game VI: Greedy Selection by Combined Value

medium

How to solve LeetCode 1686 Stone Game VI. Sort stones by combined Alice and Bob values to find the optimal greedy picking strategy.

6 min
arrayssorting

Sort Array by Increasing Frequency: Custom Sorting with Frequency Counts

easy

How to solve LeetCode 1636 Sort Array by Increasing Frequency. Count element frequencies and use a custom comparator to sort by frequency ascending, value descending.

5 min
arrayssorting

Smallest String With A Given Numeric Value: Greedy from the Right

medium

How to solve LeetCode 1663 Smallest String With A Given Numeric Value using a greedy approach. Build the lexicographically smallest string by filling from the right.

5 min
stringsgreedy

Slowest Key: Finding the Longest Key Press

easy

How to solve LeetCode 1629 Slowest Key. Compute each key's press duration from release times and track the maximum with tie-breaking.

5 min
arraysstrings

Sell Diminishing-Valued Colored Balls: Greedy Leveling Pattern

medium

How to solve LeetCode 1648 Sell Diminishing-Valued Colored Balls using sorting and greedy leveling. Maximize profit by always selling the most valuable ball.

8 min
arrayssorting

Richest Customer Wealth: Matrix Row Sum Pattern

easy

How to solve LeetCode 1672 Richest Customer Wealth by summing matrix rows. The row aggregation pattern explained with visual walkthroughs.

5 min
arraysmatrix

Reformat Phone Number: String Grouping Pattern

easy

How to solve LeetCode 1694 Reformat Phone Number with clean string processing. The digit grouping pattern explained visually.

5 min
strings

Rank Transform of a Matrix: Union-Find with Greedy Ranking

hard

How to solve LeetCode 1632 Rank Transform of a Matrix. Sort cells by value and use union-find to handle same-value constraints across rows and columns.

8 min
matrixunion-find

Path With Minimum Effort: Binary Search on the Answer

medium

How to solve LeetCode 1631 Path With Minimum Effort. Use binary search on the effort threshold combined with BFS to find the optimal path.

7 min
matrixbinary-search

Partitioning Into Minimum Number of Deci-Binary Numbers: Find the Max Digit

medium

How to solve LeetCode 1689 Partitioning Into Minimum Number of Deci-Binary Numbers. The answer is the maximum digit in the string, since each deci-binary number contributes at most 1 per position.

5 min
stringsgreedy

Number of Ways to Form a Target String Given a Dictionary

hard

How to solve LeetCode 1639 Number of Ways to Form a Target String Given a Dictionary. Use column frequency counts and dynamic programming to count valid formations.

6 min
stringsdynamic-programming

Minimum Operations to Reduce X to Zero: Sliding Window Complement

medium

How to solve LeetCode 1658 Minimum Operations to Reduce X to Zero by finding the longest subarray with a target sum. The complement sliding window pattern explained.

5 min
arrayshash-map

Minimum Number of Removals to Make Mountain Array: LIS + LDS Pattern

hard

How to solve LeetCode 1671 Minimum Number of Removals to Make Mountain Array using LIS from both sides. The mountain subsequence pattern explained with visual walkthroughs.

7 min
arraysdynamic-programming

Minimum Moves to Make Array Complementary: Difference Array Pattern

medium

How to solve LeetCode 1674 Minimum Moves to Make Array Complementary using a difference array over target sums. The sweep line counting pattern explained with visual walkthroughs.

7 min
arrayshash-map

Minimum Jumps to Reach Home: BFS with Directional State

medium

How to solve LeetCode 1654 Minimum Jumps to Reach Home. Use BFS with a (position, lastBackward) state pair to find the shortest path on a number line with forbidden positions.

6 min
dynamic-programminggraph

Minimum Initial Energy to Finish Tasks: Greedy Sorting

hard

How to solve LeetCode 1665 Minimum Initial Energy to Finish Tasks with a greedy approach. Visual walkthrough of sorting by energy surplus.

8 min
arrayssorting

Minimum Incompatibility: Bitmask DP for Subset Partitioning

hard

How to solve LeetCode 1681 Minimum Incompatibility using bitmask dynamic programming. The subset enumeration and partitioning pattern explained.

6 min
dynamic-programmingbit-manipulation

Minimum Deletions to Make String Balanced: Counting B's as You Go

medium

How to solve LeetCode 1653 Minimum Deletions to Make String Balanced. Track b_count and deletions in a single pass for an O(n) time, O(1) space solution.

5 min
stringsdynamic-programming

Minimum Deletions to Make Character Frequencies Unique: Greedy Frequency Counting

medium

How to solve LeetCode 1647 Minimum Deletions to Make Character Frequencies Unique using a greedy approach with frequency counting and sorting.

6 min
stringssorting

Minimize Deviation in Array: Max Heap Greedy Pattern

hard

How to solve LeetCode 1675 Minimize Deviation in Array using a max heap with normalization. The greedy shrinking pattern explained with visual walkthroughs.

6 min
arraysheap

Merge In Between Linked Lists: Pointer Surgery

medium

How to solve LeetCode 1669 Merge In Between Linked Lists with pointer manipulation. Visual walkthrough of splicing one list into another.

6 min
linked-lists

Maximum Repeating Substring: Simple String Matching

easy

How to solve LeetCode 1668 Maximum Repeating Substring by incrementally building repeated patterns. Visual step-by-step walkthrough.

5 min
strings

Maximum Height by Stacking Cuboids: DP with Sorting

hard

How to solve LeetCode 1691 Maximum Height by Stacking Cuboids using dynamic programming and sorting. The cuboid stacking pattern explained visually.

5 min
arraysdynamic-programming

Maximum Erasure Value: Sliding Window with Unique Elements

medium

How to solve LeetCode 1695 Maximum Erasure Value using the sliding window pattern with a set. Finding the maximum sum subarray with unique elements.

5 min
arrayshash-map

Maximize Grid Happiness: Profile DP with Bitmask

hard

How to solve LeetCode 1659 Maximize Grid Happiness using profile dynamic programming. Place introverts and extroverts on a grid to maximize total happiness.

8 min
dynamic-programmingbit-manipulation

Max Number of K-Sum Pairs: Hash Map Complement Counting

medium

How to solve LeetCode 1679 Max Number of K-Sum Pairs using hash map complement counting. Two approaches compared: hash map and two pointers.

5 min
arrayshash-map

Kth Smallest Instructions: Combinatorial Path Counting

hard

How to solve LeetCode 1643 Kth Smallest Instructions using combinatorics. Build the lexicographically k-th smallest path string one character at a time.

7 min
mathdynamic-programming

Jump Game VI: DP with Sliding Window Maximum

medium

How to solve LeetCode 1696 Jump Game VI using dynamic programming with a monotonic deque. The sliding window maximum optimization explained visually.

6 min
arraysdynamic-programming

Goal Parser Interpretation: String Replacement Patterns

easy

How to solve LeetCode 1678 Goal Parser Interpretation using simple string parsing. The character-by-character replacement pattern explained.

4 min
strings

Get Maximum in Generated Array: Simulation Pattern

easy

How to solve LeetCode 1646 Get Maximum in Generated Array using simulation. Build the array step by step and track the maximum.

5 min
arrayssimulation

Furthest Building You Can Reach: Greedy Heap Pattern

medium

How to solve LeetCode 1642 Furthest Building You Can Reach using a greedy approach with a min-heap. Visual walkthrough of the ladder and brick allocation strategy.

7 min
arraysgreedy

Find the Most Competitive Subsequence: Monotonic Stack Pattern

medium

How to solve LeetCode 1673 Find the Most Competitive Subsequence using a monotonic stack with a remaining elements budget. The greedy stack pattern explained with visual walkthroughs.

6 min
arraysstacks

Distribute Repeating Integers: Bitmask DP over Customer Subsets

hard

How to solve LeetCode 1655 Distribute Repeating Integers. Use bitmask DP to assign value frequencies to customer subsets, checking satisfiability in O(n * 3^m) time.

6 min
dynamic-programmingbit-manipulation

Determine if Two Strings Are Close: Frequency Matching Pattern

medium

How to solve LeetCode 1657 Determine if Two Strings Are Close using character frequency analysis. Learn when two strings can be transformed into each other.

5 min
stringshash-map

Design Front Middle Back Queue: Two Deques

medium

How to solve LeetCode 1670 Design Front Middle Back Queue using two balanced deques. Visual walkthrough of O(1) operations at front, middle, and back.

6 min
designlinked-lists

Delivering Boxes from Storage to Ports: Sliding Window DP

hard

How to solve LeetCode 1687 Delivering Boxes from Storage to Ports. Combine dynamic programming with a sliding window and monotonic deque to minimize delivery trips.

6 min
arraysdynamic-programming

Defuse the Bomb: Circular Sliding Window

easy

How to solve LeetCode 1652 Defuse the Bomb. Use a circular sliding window to replace each element with the sum of its neighbors in O(n) time.

5 min
arrayssliding-window

Create Sorted Array through Instructions: Fenwick Tree for Insertion Costs

hard

How to solve LeetCode 1649 Create Sorted Array through Instructions. Use a Binary Indexed Tree to count strictly less and strictly greater elements in O(log m) per insertion.

6 min
arraysbinary-search

Count the Number of Consistent Strings: Set Membership Patterns

easy

How to solve LeetCode 1684 Count the Number of Consistent Strings using set membership checking. The allowed character set pattern explained.

5 min
arraysstrings

Count Substrings That Differ by One Character

medium

How to solve LeetCode 1638 Count Substrings That Differ by One Character. Fix the mismatch position and expand to count valid pairs efficiently.

6 min
stringsdynamic-programming

Count Sorted Vowel Strings

medium

How to solve LeetCode 1641 Count Sorted Vowel Strings. Use dynamic programming or combinatorics to count lexicographically sorted vowel strings of length n.

6 min
mathdynamic-programming

Count of Matches in Tournament: Every Match Eliminates One

easy

How to solve LeetCode 1688 Count of Matches in Tournament. Recognize that each match eliminates exactly one team, making the answer always n minus 1.

4 min
mathsimulation

Concatenation of Consecutive Binary Numbers: Bit Shifting Patterns

medium

How to solve LeetCode 1680 Concatenation of Consecutive Binary Numbers using bit shifting. The modular arithmetic pattern explained.

5 min
mathbit-manipulation

Check If Two String Arrays are Equivalent: Pointer Technique

easy

How to solve LeetCode 1662 Check If Two String Arrays are Equivalent using O(1) space with four pointers. Compare concatenated strings without building them.

6 min
arraysstrings

Check Array Formation Through Concatenation

easy

How to solve LeetCode 1640 Check Array Formation Through Concatenation. Use a hash map from first elements to pieces for efficient matching.

5 min
arrayshash-map

Arithmetic Subarrays: Checking Subarrays for Arithmetic Sequences

medium

How to solve LeetCode 1630 Arithmetic Subarrays. Extract, sort, and verify constant differences for each query range.

6 min
arrayssorting

Throne Inheritance: Tree Design with Pre-Order DFS

medium

How to solve LeetCode 1600 Throne Inheritance using tree traversal and pre-order DFS. Design a system that tracks family hierarchy and inheritance order.

7 min
designtrees

Three Consecutive Odds: Simple Array Scanning

easy

How to solve LeetCode 1550 Three Consecutive Odds by counting consecutive odd numbers. A clean scanning approach with visual walkthrough.

6 min
arrays

Thousand Separator: String Building from Right to Left

easy

How to solve LeetCode 1556 Thousand Separator by grouping digits from the right. A clean string manipulation approach with visual walkthrough.

5 min
strings

Sum of All Odd Length Subarrays: Count Each Element's Contribution

easy

How to solve LeetCode 1588 Sum of All Odd Length Subarrays. A math-based counting approach lets you skip brute force and solve it in O(n).

5 min
arraysmath

Strange Printer II: Topological Sort on Color Dependencies

hard

How to solve LeetCode 1591 Strange Printer II. Model color overlaps as a dependency graph and check for a valid print order with topological sort.

6 min
matrixgraph

Stone Game V: Interval DP with Prefix Sums

hard

How to solve LeetCode 1563 Stone Game V using interval dynamic programming and prefix sums. Visual walkthrough and clean Python solution.

6 min
arraysdynamic-programming

Split Two Strings to Make Palindrome: Two-Pointer Pattern

medium

How to solve LeetCode 1616 Split Two Strings to Make Palindrome using two pointers. Visual walkthrough and clean Python solution.

6 min
stringstwo-pointers

Split a String Into the Max Number of Unique Substrings: Backtracking with a Set

medium

How to solve LeetCode 1593 Split a String Into the Max Number of Unique Substrings. Use backtracking to try every possible split point, tracking used substrings in a set to enforce uniqueness.

6 min
stringsbacktracking

Special Positions in a Binary Matrix: Row and Column Sum Trick

easy

How to solve LeetCode 1582 Special Positions in a Binary Matrix using precomputed row and column sums. Visual walkthrough and clean Python solution.

6 min
matrix

Special Array With X Elements Greater Than or Equal X: Sorting and Counting

easy

How to solve LeetCode 1608 Special Array With X Elements Greater Than or Equal X using sorting and suffix counting. Clean O(n log n) solution explained.

6 min
arraysbinary-search

Shortest Subarray to be Removed to Make Array Sorted

medium

How to solve LeetCode 1574 by finding sorted prefix and suffix segments, then using two pointers to minimize the removed middle section. Visual walkthrough, Python solution, and building blocks.

5 min
arraystwo-pointers

Replace All ?'s to Avoid Consecutive Repeating Characters

easy

How to solve LeetCode 1576 Replace All ?'s to Avoid Consecutive Repeating Characters. Scan left to right, pick from a/b/c to avoid matching neighbors, for an O(n) time O(n) space solution.

5 min
strings

Remove Max Number of Edges to Keep Graph Fully Traversable

hard

How to solve LeetCode 1579 using Union-Find with edge prioritization. Visual walkthrough of the greedy graph connectivity approach.

7 min
graphunion-find

Rearrange Spaces Between Words: Distributing Spaces Evenly

easy

How to solve LeetCode 1592 Rearrange Spaces Between Words. Count the total spaces, divide them equally among the gaps between words, and append any remainder at the end.

4 min
strings

Number of Ways Where Square of Number Is Equal to Product of Two Numbers

medium

How to solve LeetCode 1577 Number of Ways Where Square of Number Is Equal to Product of Two Numbers using hash maps to count product pairs in O(n * m) time.

6 min
arrayshash-map

Number of Ways to Split a String: Counting Splits with Equal Ones

medium

How to solve LeetCode 1573 Number of Ways to Split a String. Count the ways to split a binary string into three parts with equal numbers of ones using gap multiplication.

7 min
stringsmath

Number of Sets of K Non-Overlapping Line Segments: DP on Segments

medium

How to solve LeetCode 1621 Number of Sets of K Non-Overlapping Line Segments using dynamic programming. Visual walkthrough and clean Python solution.

6 min
mathdynamic-programming

Most Visited Sector in a Circular Track: Skip the Simulation

easy

How to solve LeetCode 1560 Most Visited Sector in a Circular Track without simulating every lap. A clean observation-based approach with visual walkthrough.

6 min
arrayssimulation

Minimum Time to Make Rope Colorful: Greedy Group Processing

medium

How to solve LeetCode 1578 Minimum Time to Make Rope Colorful using greedy processing of consecutive groups. Visual walkthrough and clean Python solution.

6 min
arraysstrings

Minimum Operations to Make Array Equal: Math Pattern

medium

How to solve LeetCode 1551 Minimum Operations to Make Array Equal using a closed-form math formula. From pairing to O(1) solution.

5 min
math

Minimum Numbers of Function Calls to Make Target Array: Reverse Engineering with Bits

medium

How to solve LeetCode 1558 Minimum Numbers of Function Calls to Make Target Array by working backwards from the target using bit manipulation. A clean greedy approach with visual walkthrough.

6 min
arraysgreedy

Minimum Number of Vertices to Reach All Nodes: Find the Sources

medium

How to solve LeetCode 1557 Minimum Number of Vertices to Reach All Nodes by identifying nodes with zero in-degree. A clean graph approach with visual walkthrough.

5 min
graph

Minimum Number of Days to Eat N Oranges: BFS with Memoization

hard

How to solve LeetCode 1553 Minimum Number of Days to Eat N Oranges using BFS with memoization. Pruning a massive search space with greedy division.

7 min
dynamic-programmingmath

Minimum Number of Days to Disconnect Island: The Answer Is Always 0, 1, or 2

hard

How to solve LeetCode 1568 Minimum Number of Days to Disconnect Island using connected component analysis. Visual walkthrough and clean Python solution.

6 min
matrixgraph

Minimum Cost to Cut a Stick: Interval DP on Segment Boundaries

hard

How to solve LeetCode 1547 Minimum Cost to Cut a Stick using interval DP. Sort the cuts, add boundaries, and fill a 2D table where dp[i][j] stores the minimum cost for all cuts between boundary i and j.

6 min
arraysdynamic-programming

Minimum Cost to Connect Two Groups of Points: Bitmask DP

hard

How to solve LeetCode 1595 Minimum Cost to Connect Two Groups of Points using bitmask DP. Ensure every point in both groups is connected.

6 min
dynamic-programmingbit-manipulation

Min Cost to Connect All Points: Minimum Spanning Tree

medium

How to solve LeetCode 1584 Min Cost to Connect All Points using Kruskal's algorithm with Union-Find. Visual walkthrough of the MST construction.

7 min
graphunion-find

Mean of Array After Removing Some Elements: Trimmed Mean

easy

How to solve LeetCode 1619 Mean of Array After Removing Some Elements. Sort, trim 5% from each end, and compute the mean.

5 min
arrayssorting

Maximum Profit of Operating a Centennial Wheel: Simulation

medium

How to solve LeetCode 1599 Maximum Profit of Operating a Centennial Wheel using simulation. Track profit at each rotation to find the optimal stopping point.

6 min
arrayssimulation

Maximum Number of Visible Points: Angle Sweep with Sliding Window

hard

How to solve LeetCode 1610 Maximum Number of Visible Points using atan2 angle conversion, sorting, and a sliding window for circular ranges.

6 min
mathsorting

Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

medium

How to solve LeetCode 1546 using prefix sums, a hash set, and a greedy reset strategy to find the maximum number of non-overlapping subarrays that sum to a target.

6 min
arrayshash-map

Maximum Number of Coins You Can Get: Greedy Triplet Picking

medium

How to solve LeetCode 1561 Maximum Number of Coins You Can Get by sorting and greedily picking the second-largest pile in each round. A clean greedy approach with visual walkthrough.

5 min
arrayssorting

Maximum Number of Achievable Transfer Requests: Backtracking with Bitmask Enumeration

hard

How to solve LeetCode 1601 Maximum Number of Achievable Transfer Requests using backtracking and bitmask enumeration. The subset enumeration pattern explained with visual walkthroughs.

7 min
arraysbacktracking

Maximum Non Negative Product in a Matrix: Dual-Tracking Grid DP

medium

How to solve LeetCode 1594 Maximum Non Negative Product in a Matrix using dynamic programming. Track both max and min products through the grid.

7 min
matrixdynamic-programming

Maximum Nesting Depth of the Parentheses: Counter Pattern

easy

How to solve LeetCode 1614 Maximum Nesting Depth of the Parentheses. Track depth with a counter instead of a stack for O(1) space.

4 min
stringsstacks

Maximum Length of Subarray With Positive Product: Tracking Sign Flips

medium

How to solve LeetCode 1567 Maximum Length of Subarray With Positive Product using dynamic programming with positive and negative length tracking. Visual walkthrough and clean Python solution.

5 min
arraysdynamic-programming

Maximal Network Rank: Graph Degree Counting

medium

How to solve LeetCode 1615 Maximal Network Rank by counting node degrees and checking shared edges. A clean graph problem explained visually.

5 min
graph

Matrix Diagonal Sum: Primary and Secondary Diagonals

easy

How to solve LeetCode 1572 Matrix Diagonal Sum by iterating once and summing both diagonals. Visual walkthrough and clean Python solution.

5 min
matrix

Make The String Great: Stack-Based Pair Removal

easy

How to solve LeetCode 1544 Make The String Great. Use a stack to remove adjacent bad pairs where one character is the lowercase version of the other.

5 min
stringsstacks

Make Sum Divisible by P: Prefix Sums and Modular Lookups

medium

How to solve LeetCode 1590 Make Sum Divisible by P. Use prefix sums with modular arithmetic and a hash map to find the shortest removable subarray in O(n) time.

6 min
arrayshash-map

Magnetic Force Between Two Balls: Binary Search on Answer

medium

How to solve LeetCode 1552 Magnetic Force Between Two Balls using binary search on the minimum distance. The binary search on answer pattern explained.

7 min
arraysbinary-search

Lexicographically Smallest String After Applying Operations: BFS State Exploration

medium

How to solve LeetCode 1625 using BFS to explore all reachable string states through add and rotate operations. A clean walkthrough of state-space search.

6 min
strings

Largest Substring Between Two Equal Characters: Hash Map First Occurrence

easy

How to solve LeetCode 1624 Largest Substring Between Two Equal Characters using a hash map to track first occurrences. Clean O(n) solution with visual walkthrough.

5 min
stringshash-map

Graph Connectivity With Threshold: Sieve Meets Union-Find

hard

How to solve LeetCode 1627 Graph Connectivity With Threshold using a sieve-based Union-Find approach. Number theory and graph connectivity explained visually.

8 min
graphunion-find

Find Valid Matrix Given Row and Column Sums: Greedy Cell-by-Cell Construction

medium

How to solve LeetCode 1605 Find Valid Matrix Given Row and Column Sums using a greedy approach. The cell-by-cell matrix construction pattern explained with visual walkthroughs.

6 min
matrixgreedy

Find Servers That Handled Most Number of Requests: Heap with Sorted Set

hard

How to solve LeetCode 1606 Find Servers That Handled Most Number of Requests using a min-heap and sorted set. The server scheduling pattern explained with visual walkthroughs.

6 min
arraysheap

Find Longest Awesome Substring: Bitmask Parity for Palindrome Substrings

hard

How to solve LeetCode 1542 Find Longest Awesome Substring. Use a bitmask to track digit frequency parities and a hash map of first occurrences to find the longest substring rearrangeable into a palindrome.

6 min
stringsbit-manipulation

Find Latest Group of Size M: Reverse Simulation with Group Tracking

medium

How to solve LeetCode 1562 Find Latest Group of Size M using reverse simulation and group size tracking. Visual walkthrough and clean Python solution.

7 min
arrayssimulation

Find Kth Bit in Nth Binary String

medium

How to solve LeetCode 1545 Find Kth Bit in Nth Binary String. Use recursion to avoid building the exponentially growing string, navigating the structure with divide and conquer.

6 min
stringssimulation

Fancy Sequence: Lazy Math with Modular Inverse

hard

How to solve LeetCode 1622 Fancy Sequence using modular inverse and lazy propagation. A clean design problem explained visually.

6 min
designmath

Even Odd Tree: Level-Order Validation

medium

How to solve LeetCode 1609 with BFS. Process each level of the tree, verify parity and ordering constraints, and return whether the tree qualifies as even-odd.

6 min
trees

Detect Cycles in 2D Grid: Union-Find on a Matrix

medium

How to solve LeetCode 1559 Detect Cycles in 2D Grid using Union-Find to detect cycles among same-character cells. A clean approach with visual walkthrough.

7 min
matrixgraph

Design Parking System: Simple Counter Pattern

easy

How to solve LeetCode 1603 Design Parking System using simple counters. A clean design problem explained with visual walkthroughs.

4 min
design

Crawler Log Folder: Depth Tracking with a Counter

easy

How to solve LeetCode 1598 Crawler Log Folder by tracking directory depth. A simple stack or counter approach explained with visuals.

6 min
stringsstacks

Count Subtrees With Max Distance Between Cities: Bitmask Enumeration

hard

How to solve LeetCode 1617 Count Subtrees With Max Distance Between Cities using bitmask enumeration and BFS. Visual walkthrough and clean Python solution.

6 min
treesbit-manipulation

Count All Possible Routes: DP on City and Fuel

hard

How to solve LeetCode 1575 Count All Possible Routes with memoized DP. Visual walkthrough of the two-dimensional state space over cities and fuel.

6 min
arraysdynamic-programming

Coordinate With Maximum Network Quality: Brute Force Simulation

medium

How to solve LeetCode 1620 Coordinate With Maximum Network Quality using brute force enumeration. Visual walkthrough and clean Python solution.

6 min
arrayssimulation

Check If String Is Transformable With Substring Sort Operations

hard

How to solve LeetCode 1585 using digit queues and greedy validation. Visual walkthrough of the substring sort transformation check.

5 min
stringssorting

Best Team With No Conflicts: Sorting Meets LIS-Style DP

medium

How to solve LeetCode 1626 Best Team With No Conflicts using sorting and longest increasing subsequence dynamic programming. Step-by-step visual walkthrough.

5 min
arraysdynamic-programming

Alert Using Same Key-Card Three or More Times: Hash Map Grouping with Sliding Window

medium

How to solve LeetCode 1604 Alert Using Same Key-Card Three or More Times in a One Hour Period using hash maps and sorting. The grouping and sliding window pattern explained with visual walkthroughs.

6 min
arrayshash-map

XOR Operation in an Array: Bit Manipulation Basics

easy

How to solve LeetCode 1486 XOR Operation in an Array. Build the array and XOR all elements together.

4 min
mathbit-manipulation

Water Bottles: Simulation and Math

easy

How to solve LeetCode 1518 Water Bottles. Visual walkthrough of the bottle exchange simulation.

4 min
mathsimulation

The kth Factor of n: Efficient Factor Enumeration

medium

How to solve LeetCode 1492 The kth Factor of n by iterating up to sqrt(n) to find factors in sorted order.

5 min
math

The k Strongest Values in an Array: Two-Pointer Selection

medium

How to solve LeetCode 1471 The k Strongest Values in an Array using sorting and two pointers. Clean O(n log n) solution explained step by step.

5 min
arrayssorting

Subrectangle Queries: Design a 2D Matrix Updater

medium

How to solve LeetCode 1476 Subrectangle Queries by designing a class that updates rectangular regions and queries cell values. Clean solution explained step by step.

6 min
arraysdesign

String Compression II: DP on Run-Length Encoding

hard

How to solve LeetCode 1531 String Compression II using dynamic programming to minimize run-length encoded length after deletions.

6 min
stringsdynamic-programming

Stone Game IV: Game Theory Meets Dynamic Programming

hard

How to solve LeetCode 1510 Stone Game IV. Visual DP walkthrough for game states with perfect square moves.

6 min
dynamic-programmingmath

Shuffle the Array: Interleaving Two Halves in Place

easy

How to solve LeetCode 1470 Shuffle the Array by interleaving elements from two halves. Clean O(n) solution explained step by step.

5 min
arrays

Shuffle String: Index Mapping Pattern

easy

How to solve LeetCode 1528 Shuffle String using direct index mapping. The permutation placement pattern explained with visual walkthroughs.

4 min
arraysstrings

Running Sum of 1d Array: Your First Prefix Sum

easy

How to solve LeetCode 1480 Running Sum of 1d Array with prefix sums. Clean O(n) solution explained step by step.

4 min
arrays

Reorder Routes to Make All Paths Lead to City Zero: BFS on Directed Trees

medium

How to solve LeetCode 1466 Reorder Routes to Make All Paths Lead to the City Zero using BFS/DFS to count edges pointing away from the root.

6 min
graphtrees

Reformat Date

easy

How to solve LeetCode 1507 Reformat Date with string parsing and formatting. A clean approach to date conversion problems.

5 min
strings

Range Sum of Sorted Subarray Sums

medium

How to solve LeetCode 1508 Range Sum of Sorted Subarray Sums. Generate all subarray sums, sort, and sum a range.

6 min
arrayssorting

Probability of Two Boxes Having the Same Number of Distinct Balls: Combinatorial Backtracking

hard

How to solve LeetCode 1467 Probability of a Two Boxes Having the Same Number of Distinct Balls using backtracking with multinomial coefficients.

7 min
mathdynamic-programming

Path with Maximum Probability: Modified Dijkstra's Algorithm

medium

How to solve LeetCode 1514 Path with Maximum Probability. Visual walkthrough of Dijkstra's with probability multiplication.

6 min
graphheap

Path Crossing: Hash Set Coordinate Tracking

easy

How to solve LeetCode 1496 Path Crossing using a hash set to detect revisited coordinates. Track movements on a 2D grid with O(n) time.

5 min
stringshash-map

Parallel Courses II: Bitmask DP for Course Scheduling

hard

How to solve LeetCode 1494 Parallel Courses II using bitmask dynamic programming to find the minimum number of semesters.

7 min
dynamic-programmingbit-manipulation

Paint House III: Neighborhood-Constrained DP

hard

How to solve LeetCode 1473 Paint House III using 3D dynamic programming with house, color, and neighborhood count dimensions. Step-by-step explanation.

7 min
dynamic-programming

Number of Substrings With Only 1s: Counting Consecutive Groups

medium

How to solve LeetCode 1513 Number of Substrings With Only 1s using consecutive counting and the n*(n+1)/2 formula.

6 min
stringsmath

Number of Substrings With Only 1s: Counting Consecutive Groups

medium

How to solve LeetCode 1513 Number of Substrings With Only 1s. Visual walkthrough of the consecutive counting pattern.

6 min
stringsmath

Number of Subsequences That Satisfy the Given Sum Condition: Sort and Two Pointers

medium

How to solve LeetCode 1498 using sorting and two pointers to count valid subsequences. Combine binary search intuition with modular exponentiation.

6 min
arraysbinary-search

Number of Sub-arrays With Odd Sum: Prefix Sum Parity

medium

How to solve LeetCode 1524 Number of Sub-arrays With Odd Sum. Track prefix sum parity to count subarrays with odd sums in O(n).

6 min
arraysmath

Number of Nodes in the Sub-Tree With the Same Label

medium

How to solve LeetCode 1519 Number of Nodes in the Sub-Tree With the Same Label. Use DFS with a shared count array and a before/after snapshot trick to isolate each subtree's contribution.

5 min
treesgraph

Number of Good Ways to Split a String: Prefix-Suffix Distinct Counting

medium

How to solve LeetCode 1525 Number of Good Ways to Split a String using prefix and suffix distinct character counts. The split-point scanning pattern explained with visual walkthroughs.

5 min
stringshash-map

Number of Good Leaf Nodes Pairs: DFS Distance Propagation

medium

How to solve LeetCode 1530 Number of Good Leaf Nodes Pairs using DFS with distance list propagation.

7 min
trees

Minimum Swaps to Arrange a Binary Grid: Greedy Row Swap Pattern

medium

How to solve LeetCode 1536 Minimum Swaps to Arrange a Binary Grid using a greedy approach with trailing zeros. Visual walkthrough and clean Python solution.

6 min
matrixgreedy

Minimum Suffix Flips: Greedy State Tracking

medium

How to solve LeetCode 1529 Minimum Suffix Flips using greedy state tracking. The suffix flip counting pattern explained with visual walkthroughs.

6 min
stringsgreedy

Minimum Increments on Subarrays to Form a Target Array: Greedy Stacking

hard

How to solve LeetCode 1526 Minimum Number of Increments on Subarrays to Form a Target Array using a greedy approach. The stacking operations pattern explained with visual walkthroughs.

7 min
arraysstacks

Minimum Number of Days to Make m Bouquets: Binary Search on Answer

medium

How to solve LeetCode 1482 using binary search on the answer. Learn to identify when to binary search over the solution space.

6 min
arraysbinary-search

Minimum Insertions to Balance a Parentheses String: Greedy Counter Pattern

medium

How to solve LeetCode 1541 Minimum Insertions to Balance a Parentheses String using greedy counting. Visual walkthrough and clean Python solution.

6 min
stringsstacks

Minimum Difference Between Largest and Smallest Value in Three Moves

medium

How to solve LeetCode 1509 Minimum Difference Between Largest and Smallest Value in Three Moves. Sort and check four windows.

5 min
arrayssorting

Maximum Product of Two Elements in an Array: Finding the Top Two

easy

How to solve LeetCode 1464 Maximum Product of Two Elements in an Array by tracking the two largest values in a single pass.

5 min
arrayssorting

Maximum Number of Non-Overlapping Substrings: Greedy Interval Selection on Strings

hard

How to solve LeetCode 1520 Maximum Number of Non-Overlapping Substrings. Expand character intervals, validate them, and greedily pick non-overlapping ones.

6 min
stringsgreedy

Maximum Area of a Piece of Cake After Cuts: Greedy Gap Finding

medium

How to solve LeetCode 1465 Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts by finding the largest gaps between sorted cut positions.

6 min
arraysgreedy

Max Value of Equation: Monotone Deque Optimization

hard

How to solve LeetCode 1499 using a monotone deque to maximize yi + yj + |xi - xj| with a distance constraint. Sliding window maximum pattern in O(n).

5 min
arraysheap

Making File Names Unique: Hash Map Tracking

medium

How to solve LeetCode 1487 Making File Names Unique using a hash map to track used names and next available suffix.

5 min
stringshash-map

Longest Subarray of 1's After Deleting One Element: Sliding Window

medium

How to solve LeetCode 1493 Longest Subarray of 1's After Deleting One Element using a sliding window that tolerates at most one zero.

6 min
arraysdynamic-programming

Least Number of Unique Integers after K Removals: Greedy Frequency Pruning

medium

How to solve LeetCode 1481 Least Number of Unique Integers after K Removals using frequency counting and greedy removal. Clean solution explained step by step.

5 min
arrayshash-map

Last Moment Before All Ants Fall Out of a Plank

medium

How to solve LeetCode 1503 Last Moment Before All Ants Fall Out of a Plank. The collision insight that reduces the problem to a single pass.

6 min
arrayssimulation

Kth Missing Positive Number: Binary Search on Missing Counts

easy

How to solve LeetCode 1539 Kth Missing Positive Number using binary search on the count of missing values. Visual walkthrough and clean Python solution.

5 min
arraysbinary-search

Kth Ancestor of a Tree Node: Binary Lifting

hard

How to solve LeetCode 1483 using binary lifting. Precompute ancestors at powers of 2 to answer ancestor queries in O(log k) time.

7 min
treesbinary-search

Get the Maximum Score: Two-Pointer Path Switching

hard

How to solve LeetCode 1537 Get the Maximum Score using two pointers and greedy path selection at intersections. Visual walkthrough and Python solution.

5 min
arraystwo-pointers

Find Two Non-overlapping Sub-arrays Each With Target Sum: Sliding Window Meets Prefix Minimum

medium

How to solve LeetCode 1477 Find Two Non-overlapping Sub-arrays Each With Target Sum using sliding window and prefix minimum. Clean O(n) solution explained step by step.

6 min
arrayshash-map

Find the Winner of an Array Game: Simulation with Early Exit

medium

How to solve LeetCode 1535 Find the Winner of an Array Game using simulation with an optimization for large k.

6 min
arrayssimulation

Find Critical and Pseudo-Critical Edges in MST: Union-Find Classification

hard

How to solve LeetCode 1489 Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree using Kruskal's algorithm and Union-Find to classify each edge.

7 min
graphsorting

Find a Value of a Mysterious Function Closest to Target: Bit-Bounded Set Propagation

hard

How to solve LeetCode 1521 Find a Value of a Mysterious Function Closest to Target. Use the bounded-set-of-AND-values technique to search all subarrays in near-linear time.

6 min
binary-searchbit-manipulation

Final Prices With a Special Discount: Monotonic Stack Basics

easy

How to solve LeetCode 1475 Final Prices With a Special Discount in a Shop using a monotonic stack. Clean O(n) solution explained step by step.

6 min
arraysstacks

Design Browser History: Stack-Based Navigation

medium

How to solve LeetCode 1472 Design Browser History using a list with a pointer. Clean O(1) operations explained step by step.

6 min
designlinked-lists

Count Submatrices With All Ones

medium

How to solve LeetCode 1504 Count Submatrices With All Ones using consecutive-ones prefix and upward expansion.

5 min
matrixdynamic-programming

Count Odd Numbers in an Interval Range: A Math Shortcut

easy

How to solve LeetCode 1523 Count Odd Numbers in an Interval Range. Use floor division to count odd numbers between two endpoints in O(1).

5 min
math

Count Good Triplets: Triple Loop with Conditions

easy

How to solve LeetCode 1534 Count Good Triplets using a triple loop approach with absolute difference conditions.

5 min
arrays

Cherry Pickup II: Two Robots Collecting Maximum Cherries

hard

How to solve LeetCode 1463 Cherry Pickup II using dynamic programming with two robots moving through a grid simultaneously.

7 min
arraysdynamic-programming

Check If Array Pairs Are Divisible by k: Remainder Counting

medium

How to solve LeetCode 1497 using remainder frequency counting. Pair elements whose remainders sum to k for O(n) validation.

6 min
arrayshash-map

Can Make Arithmetic Progression From Sequence: Sort and Verify

easy

How to solve LeetCode 1502 by sorting and checking consecutive differences. A clean O(n log n) approach to validate arithmetic progressions.

5 min
arrayssorting

Can Convert String in K Moves: Shift Counting Pattern

medium

How to solve LeetCode 1540 Can Convert String in K Moves using character shift differences and move assignment. Visual walkthrough and Python solution.

6 min
stringshash-map

Best Position for a Service Centre: The Geometric Median

hard

How to solve LeetCode 1515 Best Position for a Service Centre. Visual walkthrough of Weiszfeld's algorithm for the geometric median.

6 min
math

Avoid Flood in The City: Greedy Dry Day Assignment

medium

How to solve LeetCode 1488 Avoid Flood in The City using hash maps and a sorted set of dry days for greedy assignment.

7 min
arrayshash-map

Average Salary Excluding Min and Max: Single Pass Array Scan

easy

How to solve LeetCode 1491 Average Salary Excluding the Minimum and Maximum Salary with a single pass to find min, max, and sum.

6 min
arrayssorting

Allocate Mailboxes: DP Meets the Median Trick

hard

How to solve LeetCode 1478 Allocate Mailboxes using dynamic programming with median optimization. Clean solution explained step by step.

5 min
dynamic-programmingmath

The k-th Happy String of Length n: Backtracking with Pruning

medium

How to solve LeetCode 1415 using backtracking to generate happy strings in lexicographical order. Skip directly to the k-th result.

7 min
stringsbacktracking

String Matching in an Array: Substring Detection

easy

How to solve LeetCode 1408 String Matching in an Array by checking all pairs for substring relationships. Visual walkthrough with Python solution.

4 min
arraysstrings

Stone Game III: Optimal Play with Suffix DP

hard

How to solve LeetCode 1406 Stone Game III using suffix sum DP and minimax reasoning. Visual walkthrough of the state transitions with Python solution.

5 min
dynamic-programming

Simplified Fractions: GCD-Based Enumeration

medium

How to solve LeetCode 1447 Simplified Fractions using GCD to enumerate all proper fractions in lowest terms. Learn the GCD filtering pattern with visual walkthroughs.

6 min
math

Restore The Array: String Partition DP

hard

How to solve LeetCode 1416 using dynamic programming to count valid ways to split a digit string into numbers between 1 and k.

7 min
stringsdynamic-programming

Reformat The String: Interleaving Letters and Digits

easy

How to solve LeetCode 1417 Reformat The String. Separate characters by type and interleave them, placing the larger group first.

4 min
strings

Reducing Dishes: Greedy Sorting for Maximum Satisfaction

hard

How to solve LeetCode 1402 Reducing Dishes with sorting and a greedy running sum. Pick the most satisfying dishes first and stop when adding more would hurt.

8 min
arraysgreedy

Rearrange Words in a Sentence: Stable Sort by Length

medium

How to solve LeetCode 1451 Rearrange Words in a Sentence using stable sort. Visual walkthrough of sorting words by length while preserving order.

4 min
stringssorting

Queries on a Permutation With Key: Simulate and Track

medium

How to solve LeetCode 1409 Queries on a Permutation With Key using direct simulation. Visual walkthrough of the move-to-front operation with Python solution.

6 min
arrayssimulation

Pseudo-Palindromic Paths in a Binary Tree: Bit Manipulation on Tree Paths

medium

How to solve LeetCode 1457 Pseudo-Palindromic Paths in a Binary Tree using DFS with bit manipulation to track character frequencies along root-to-leaf paths.

6 min
treesbit-manipulation

Pizza With 3n Slices: Circular DP Selection

hard

How to solve LeetCode 1388 Pizza With 3n Slices using circular array DP. Select n non-adjacent elements from a circular array to maximize the sum.

6 min
dynamic-programminggreedy

Favorite Companies: Subset Checking with Sets

medium

How to solve LeetCode 1452 People Whose List of Favorite Companies Is Not a Subset of Another List using set operations and pairwise comparison.

4 min
arraysstrings

Number of Ways to Wear Different Hats: Bitmask DP Pattern

hard

How to solve LeetCode 1434 Number of Ways to Wear Different Hats to Each Other using bitmask dynamic programming.

5 min
dynamic-programmingbit-manipulation

Number of Ways to Paint N x 3 Grid: Row State DP

hard

How to solve LeetCode 1411 using dynamic programming with row state transitions. Track pattern types across rows to count valid colorings.

6 min
dynamic-programming

Number of Ways of Cutting a Pizza

hard

How to solve LeetCode 1444. Use dynamic programming with prefix sums to count ways to cut a pizza into k pieces where each piece contains at least one apple.

6 min
arraysdynamic-programming

Number of Students Doing Homework at a Given Time: Interval Containment Check

easy

How to solve LeetCode 1450 Number of Students Doing Homework at a Given Time with a simple linear scan. Learn the interval containment pattern with visual walkthroughs.

5 min
arrays

Number of Steps to Reduce a Number in Binary Representation to One

medium

How to solve LeetCode 1404 Number of Steps to Reduce a Number in Binary Representation to One. Simulate binary operations from right to left, tracking carry propagation. O(n) time, O(1) space.

5 min
stringsbit-manipulation

Minimum Value to Get Positive Step by Step Sum: Prefix Sum Pattern

easy

How to solve LeetCode 1413 by computing prefix sums and finding the minimum. A clean application of the prefix sum pattern.

6 min
arrays

Minimum Time to Collect All Apples in a Tree

medium

How to solve LeetCode 1443. Use DFS to find the minimum time to collect all apples in an undirected tree, counting only edges on paths to apple nodes.

5 min
treesgraph

Minimum Subsequence in Non-Increasing Order

easy

How to solve LeetCode 1403 Minimum Subsequence in Non-Increasing Order using a greedy approach. Sort descending and greedily take the largest elements until the taken sum exceeds the remaining sum.

7 min
arraysgreedy

Minimum Number of Frogs Croaking: Tracking Concurrent Sequences

medium

How to solve LeetCode 1419 Minimum Number of Frogs Croaking. Track the state of each frog through the c-r-o-a-k sequence using counters to find the minimum number of concurrent frogs.

5 min
strings

Maximum Score After Splitting a String: Counting Zeros and Ones

easy

How to solve LeetCode 1422 Maximum Score After Splitting a String. Track zeros on the left and ones on the right as you sweep through each split point.

6 min
strings

Maximum Points You Can Obtain from Cards: Sliding Window on Edges

medium

How to solve LeetCode 1423 Maximum Points You Can Obtain from Cards using a sliding window minimum approach. Visual walkthrough and clean Python solution.

5 min
arrayssliding-window

Maximum Vowels in a Substring: Sliding Window Pattern

medium

How to solve LeetCode 1456 Maximum Number of Vowels in a Substring of Given Length using the sliding window pattern. Visual walkthrough of fixed-size window technique.

5 min
stringssliding-window

Maximum Darts in a Circular Dartboard: Angular Sweep

hard

How to solve LeetCode 1453 Maximum Number of Darts Inside of a Circular Dartboard using angular sweep and geometry. Hard math problem explained visually.

7 min
math

Max Dot Product of Two Subsequences: 2D DP Pattern

hard

How to solve LeetCode 1458 Max Dot Product of Two Subsequences using dynamic programming. A clear walkthrough of the 2D DP approach for matching subsequence elements.

6 min
arraysdynamic-programming

Max Difference You Can Get From Changing an Integer: Greedy Digit Replacement

medium

How to solve LeetCode 1432 Max Difference You Can Get From Changing an Integer using greedy digit replacement. Visual walkthrough and clean Python solution.

6 min
mathgreedy

Make Two Arrays Equal by Reversing Subarrays: Frequency Count Pattern

easy

How to solve LeetCode 1460 Make Two Arrays Equal by Reversing Subarrays using frequency counting. Why subarray reversals are a red herring and element frequency is all that matters.

5 min
arrayshash-map

Longest Happy String: Greedy Heap Construction

medium

How to solve LeetCode 1405 Longest Happy String using a greedy approach with a max heap. Visual walkthrough of character selection with Python solution.

5 min
stringsgreedy

Longest Happy Prefix: KMP Failure Function

hard

How to solve LeetCode 1392 Longest Happy Prefix using the KMP failure function to find the longest proper prefix that is also a suffix.

6 min
strings

Longest Continuous Subarray With Absolute Diff at Most Limit: Monotonic Deque Pattern

medium

How to solve LeetCode 1438 using a sliding window with two monotonic deques to track the running min and max.

7 min
arraysheap

Kids With the Greatest Number of Candies: Find Max and Compare

easy

How to solve LeetCode 1431 Kids With the Greatest Number of Candies. A clean one-pass solution with visual walkthrough.

5 min
arrays

HTML Entity Parser: String Replacement with a Map

medium

How to solve LeetCode 1410 HTML Entity Parser using a hash map for entity lookup. Visual walkthrough of the scanning and replacement process with Python solution.

5 min
stringshash-map

Four Divisors: Efficient Divisor Counting

medium

How to solve LeetCode 1390 Four Divisors by efficiently finding and counting divisors using square root optimization.

4 min
arraysmath

Form Largest Integer With Digits That Add up to Target: DP Greedy Reconstruction

hard

How to solve LeetCode 1449 Form Largest Integer With Digits That Add up to Target using dynamic programming with greedy digit selection. Learn the DP reconstruction pattern with visual walkthroughs.

7 min
arraysdynamic-programming

Find Minimum Fibonacci Numbers Whose Sum Is K: Greedy Decomposition

medium

How to solve LeetCode 1414 using a greedy approach with Fibonacci numbers. Always pick the largest Fibonacci number that fits.

5 min
mathgreedy

Find the Kth Smallest Sum of a Matrix With Sorted Rows

hard

How to solve LeetCode 1439. Use a min-heap to efficiently enumerate matrix row sums from smallest to largest without generating all combinations.

6 min
arraysbinary-search

Find Lucky Integer in an Array: Frequency Counting Made Simple

easy

How to solve LeetCode 1394 Find Lucky Integer in an Array using a hash map to count frequencies. Clean O(n) solution explained step by step.

5 min
arrayshash-map

Find All Good Strings: Digit DP Meets KMP

hard

How to solve LeetCode 1397 Find All Good Strings using digit DP combined with the KMP failure function. Count strings in a range that avoid a forbidden substring.

6 min
stringsdynamic-programming

Display Table of Food Orders in a Restaurant: Organizing with Hash Maps

medium

How to solve LeetCode 1418 Display Table of Food Orders. Use nested hash maps to aggregate orders by table and food item, then build the sorted output table.

5 min
arrayshash-map

Diagonal Traverse II: Grouping by Anti-Diagonals

medium

How to solve LeetCode 1424 Diagonal Traverse II using anti-diagonal grouping. Visual walkthrough for jagged 2D array diagonal traversal.

5 min
arrayssorting

Destination City: Hash Set Lookup Pattern

easy

How to solve LeetCode 1436 Destination City using a hash set to find the city with no outgoing path.

5 min
stringshash-map

Design Underground System: Two Hash Maps for Travel Time Tracking

medium

How to solve LeetCode 1396 Design Underground System using two hash maps to track passenger check-ins and aggregate route travel times.

5 min
designhash-map

Create Target Array in the Given Order: Simulation Pattern

easy

How to solve LeetCode 1389 Create Target Array in the Given Order using list insertion simulation.

4 min
arrayssimulation

Course Schedule IV: Transitive Closure with Floyd-Warshall

medium

How to solve LeetCode 1462 Course Schedule IV using Floyd-Warshall to build a reachability matrix. Precompute all prerequisite relationships for constant-time queries.

6 min
graph

Count Triplets That Can Form Two Arrays of Equal XOR

medium

How to solve LeetCode 1442. Find triplets where XOR of two subarrays are equal by recognizing that this means the XOR of the entire range is zero.

5 min
arrayshash-map

Count Number of Teams: Fix the Middle Element

medium

How to solve LeetCode 1395 Count Number of Teams by fixing the middle element and counting contributions from both sides.

6 min
arrays

Count Largest Group: Digit Sum Grouping

easy

How to solve LeetCode 1399 Count Largest Group. Group numbers 1 to n by their digit sum using a hash map, find the maximum group size, and count how many groups share that size.

4 min
mathhash-map

Count Good Nodes in Binary Tree: DFS with Path Maximum

medium

How to solve LeetCode 1448 Count Good Nodes in Binary Tree using DFS with a running path maximum. Learn the ancestor-tracking pattern with visual walkthroughs.

6 min
treesdfs

Construct K Palindrome Strings: Counting Odd Frequencies

medium

How to solve LeetCode 1400 Construct K Palindrome Strings using character frequency counting. The greedy insight that connects odd-frequency characters to palindrome feasibility.

5 min
stringshash-map

Constrained Subsequence Sum: DP with Monotonic Deque

hard

How to solve LeetCode 1425 Constrained Subsequence Sum using dynamic programming with a monotonic deque. Visual walkthrough and clean Python solution.

7 min
arraysdynamic-programming

Consecutive Characters: Finding the Power of a String

easy

How to solve LeetCode 1446 Consecutive Characters with a single-pass scan. Learn the streak-counting pattern with visual walkthroughs.

5 min
strings

Circle and Rectangle Overlapping: Closest Point Distance Check

medium

How to solve LeetCode 1401 Circle and Rectangle Overlapping. Clamp the circle center to the rectangle bounds and check whether the closest point falls within the radius.

5 min
math

Check if There is a Valid Path in a Grid: Pipe Connection BFS

medium

How to solve LeetCode 1391 Check if There is a Valid Path in a Grid using BFS with directional connection validation.

6 min
arraysgraph

Check If All 1s Are at Least Length K Places Away: Linear Scan Pattern

easy

How to solve LeetCode 1437 Check If All 1's Are at Least Length K Places Away with a single pass through the array.

5 min
arrays

Check If a Word Occurs As a Prefix: String Scanning

easy

How to solve LeetCode 1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence. Simple string prefix matching explained visually.

4 min
strings

Check If a String Contains All Binary Codes of Size K: Sliding Window + HashSet

medium

How to solve LeetCode 1461 Check If a String Contains All Binary Codes of Size K using a sliding window with a hash set. A clean approach to substring enumeration.

6 min
stringshash-map

Check If a String Can Break Another String: Sorted Comparison Pattern

medium

How to solve LeetCode 1433 Check If a String Can Break Another String using sorting and greedy comparison.

5 min
stringsgreedy

Build Array Where You Can Find The Maximum Exactly K Comparisons: 3D Dynamic Programming

hard

How to solve LeetCode 1420 Build Array Where You Can Find The Maximum Exactly K Comparisons. Use 3D DP tracking position, current maximum, and remaining search cost.

6 min
dynamic-programming

Build an Array With Stack Operations

medium

How to solve LeetCode 1441. Simulate Push and Pop operations on a stack to match a target array from a stream of consecutive integers.

5 min
arraysstacks

Validate Binary Tree Nodes: In-Degree + BFS

medium

How to solve LeetCode 1361 Validate Binary Tree Nodes. Count in-degrees to find the root, then BFS to confirm all nodes are reachable in one connected tree.

7 min
treesgraph

Tweet Counts Per Frequency: Design with Sorted Buckets

medium

How to solve LeetCode 1348 Tweet Counts Per Frequency. Design a data structure to record tweets and query counts by minute, hour, or day frequency.

7 min
designhash-map

Time Needed to Inform All Employees: Tree DFS Pattern

medium

How to solve LeetCode 1376 Time Needed to Inform All Employees using DFS on a tree. Find the maximum root-to-leaf path sum with visual walkthroughs.

7 min
treesgraph

The K Weakest Rows in a Matrix: Binary Search + Sorting

easy

How to solve LeetCode 1337 The K Weakest Rows in a Matrix. Visual walkthrough using binary search to count soldiers and sorting to find weakest rows.

5 min
arraysbinary-search

Sum of Nodes with Even-Valued Grandparent

medium

How to solve LeetCode 1315 Sum of Nodes with Even-Valued Grandparent. Tree DFS with grandparent tracking explained with visual diagrams.

5 min
trees

Sort the Matrix Diagonally: Diagonal-by-Diagonal Sorting

medium

How to solve LeetCode 1329 Sort the Matrix Diagonally using diagonal extraction and sorting. Group cells by diagonal index and sort each group independently.

5 min
arraysmatrix

Sort Integers by The Power Value: Collatz Memoization

medium

How to solve LeetCode 1387 Sort Integers by The Power Value using memoized Collatz sequence computation and custom sorting.

5 min
dynamic-programmingsorting

Sort Integers by The Number of 1 Bits: Custom Sort with Bit Counting

easy

How to solve LeetCode 1356 Sort Integers by The Number of 1 Bits using custom sorting with bit counting. Visual walkthrough and Python solution.

5 min
arraysbit-manipulation

Remove Palindromic Subsequences: The Tricky Two-Letter Insight

easy

How to solve LeetCode 1332 Remove Palindromic Subsequences. The answer is always 0, 1, or 2 because the string only contains 'a' and 'b'.

4 min
strings

Reduce Array Size to The Half: Greedy Frequency Counting

medium

How to solve LeetCode 1338 Reduce Array Size to The Half with hash maps and greedy selection. Visual walkthrough of the frequency-based approach.

5 min
arrayshash-map

Rank Transform of an Array: Sort and Map

easy

How to solve LeetCode 1331 Rank Transform of an Array using sorting and hash map lookup. Replace each element with its rank in O(n log n) time.

5 min
arrayshash-map

Rank Teams by Votes: Positional Sorting Pattern

medium

How to solve LeetCode 1366 Rank Teams by Votes using positional vote counting and custom sorting. Step-by-step visual walkthrough with complexity analysis.

6 min
arrayshash-map

Product of the Last K Numbers: Prefix Products with Zero Reset

medium

How to solve LeetCode 1352 Product of the Last K Numbers. Use a prefix product array with zero-reset to support O(1) product queries.

6 min
arraysmath

Number of Times Binary String Is Prefix-Aligned: Max Tracking Pattern

medium

How to solve LeetCode 1375 Number of Times Binary String Is Prefix-Aligned using running maximum tracking. The prefix alignment pattern explained with visual walkthroughs.

6 min
arrays

Number of Substrings Containing All Three Characters: Sliding Window

medium

How to solve LeetCode 1358 Number of Substrings Containing All Three Characters using a sliding window approach. Visual walkthrough and Python solution.

5 min
stringssliding-window

Number of Sub-arrays of Size K and Average >= Threshold

medium

How to solve LeetCode 1343. Use a fixed-size sliding window to count sub-arrays whose average meets a threshold in O(n) time.

3 min
arrayssliding-window

Number of Steps to Reduce a Number to Zero: Simulation and Bit Tricks

easy

How to solve LeetCode 1342 Number of Steps to Reduce a Number to Zero. Simulate the process or count bits for an O(1)-ish approach.

4 min
mathbit-manipulation

Number of Operations to Make Network Connected

medium

How to solve LeetCode 1319 Number of Operations to Make Network Connected. Union-Find for graph connectivity explained with visual diagrams.

6 min
graphunion-find

Number of Days Between Two Dates: Date-to-Day Conversion

easy

How to solve LeetCode 1360 Number of Days Between Two Dates. Convert each date string to a total day count from a reference point, then subtract.

6 min
mathstrings

Minimum Number of Taps to Open to Water a Garden: Greedy Interval Covering

hard

How to solve LeetCode 1326 Minimum Number of Taps to Open to Water a Garden using greedy interval covering. Reduce to Jump Game II with visual walkthrough.

6 min
arraysgreedy

Minimum Number of Steps to Make Two Strings Anagram

medium

How to solve LeetCode 1347 Minimum Number of Steps to Make Two Strings Anagram. Use character frequency counting to find the minimum replacements needed.

4 min
stringshash-map

Minimum Flips to Make a OR b Equal to c

medium

How to solve LeetCode 1318 Minimum Flips to Make a OR b Equal to c. Bit manipulation explained with visual diagrams.

4 min
bit-manipulation

Minimum Distance to Type a Word Using Two Fingers: DP on Finger State

hard

How to solve LeetCode 1320 Minimum Distance to Type a Word Using Two Fingers using dynamic programming on finger positions. Clean Python solution with visual walkthrough.

8 min
dynamic-programming

Minimum Difficulty of a Job Schedule: DP with Day Partitions

hard

How to solve LeetCode 1335 Minimum Difficulty of a Job Schedule with dynamic programming. Visual walkthrough of the day-partition DP approach.

7 min
dynamic-programming

Minimum Cost to Make at Least One Valid Path in a Grid: 0-1 BFS Pattern

hard

How to solve LeetCode 1368 using 0-1 BFS with a deque. Learn when edges have only weights 0 and 1, why a deque replaces the priority queue, and how to apply this pattern to grid shortest-path problems.

8 min
arraysgraph

Maximum Sum BST in Binary Tree: Post-Order Validation

hard

How to solve LeetCode 1373 Maximum Sum BST in Binary Tree using post-order DFS with BST validation. The bottom-up tree pattern explained with visual walkthroughs.

7 min
treesdynamic-programming

Maximum Students Taking Exam: Bitmask DP on Rows

hard

How to solve LeetCode 1349 Maximum Students Taking Exam. Use bitmask dynamic programming to find the maximum students that can sit without cheating.

7 min
arraysdynamic-programming

Maximum Product of Splitted Binary Tree: Subtree Sum DFS

medium

How to solve LeetCode 1339 Maximum Product of Splitted Binary Tree. Visual walkthrough of the two-pass DFS approach to maximize edge-cut products.

6 min
treesdynamic-programming

Maximum Performance of a Team: Sort + Min-Heap

hard

How to solve LeetCode 1383 Maximum Performance of a Team using greedy sorting and a min-heap.

6 min
arraysgreedy

Maximum Number of Events That Can Be Attended: Greedy Heap Pattern

medium

How to solve LeetCode 1353 Maximum Number of Events That Can Be Attended using a greedy approach with a min-heap. Visual walkthrough and Python solution.

6 min
arraysgreedy

Maximum 69 Number: Greedy Digit Replacement

easy

How to solve LeetCode 1323 Maximum 69 Number using a greedy approach. Find the first 6 and change it to 9 for the maximum value.

4 min
mathgreedy

Matrix Block Sum

medium

How to solve LeetCode 1314 Matrix Block Sum. Prefix sum over a 2D matrix explained with visual diagrams.

6 min
arraysmatrix

Lucky Numbers in a Matrix: Row Min Meets Column Max

easy

How to solve LeetCode 1380 Lucky Numbers in a Matrix. Find elements that are the minimum in their row and maximum in their column using a clean two-pass approach.

6 min
arraysmatrix

Longest ZigZag Path in a Binary Tree: DFS Direction Tracking

medium

How to solve LeetCode 1372 Longest ZigZag Path in a Binary Tree using DFS with direction tracking. The zigzag path pattern explained with visual walkthroughs.

6 min
treesdynamic-programming

Linked List in Binary Tree: Subpath Matching with DFS

medium

How to solve LeetCode 1367 by combining two DFS functions to check if a linked list matches any downward path in a binary tree.

6 min
linked-liststrees

Largest Multiple of Three: Greedy Digit-Sum Modular Arithmetic

hard

How to solve LeetCode 1363 Largest Multiple of Three. Use the divisibility rule for 3 and greedy removal of the smallest digits to maximize the result.

6 min
dynamic-programminggreedy

Jump Game V: DP on Sorted Values

hard

How to solve LeetCode 1340 Jump Game V with dynamic programming and sorted processing. Visual walkthrough of the value-sorted DP approach.

6 min
arraysdynamic-programming

Jump Game IV: BFS with Same-Value Jumps

hard

How to solve LeetCode 1345 Jump Game IV. Use BFS with a hash map of same-value indices to find the minimum jumps to the last index.

6 min
arrayshash-map

Increasing Decreasing String: Zigzag Character Picking

easy

How to solve LeetCode 1370 Increasing Decreasing String by counting character frequencies and sweeping the alphabet forward and backward to build a zigzag result.

6 min
stringshash-map

How Many Numbers Are Smaller Than the Current Number: Sorting and Counting Pattern

easy

How to solve LeetCode 1365 How Many Numbers Are Smaller Than the Current Number using sorting and a hash map. Build a rank map from sorted positions to count smaller elements in O(n log n) time.

5 min
arrayshash-map

Generate a String With Characters That Have Odd Counts: Parity Trick

easy

How to solve LeetCode 1374 Generate a String With Characters That Have Odd Counts using a simple parity observation. The even-odd construction pattern explained with visual walkthroughs.

4 min
strings

Frog Position After T Seconds: BFS with Probability Tracking

hard

How to solve LeetCode 1377 Frog Position After T Seconds using BFS with probability propagation. Tree traversal and probability splitting explained with visual walkthroughs.

8 min
treesgraph

Find the Longest Substring Containing Vowels in Even Counts: Bitmask + HashMap Pattern

medium

How to solve LeetCode 1371 Find the Longest Substring Containing Vowels in Even Counts using bitmask state and hash map. The parity tracking pattern explained with visual walkthroughs.

6 min
stringshash-map

Find the Distance Value Between Two Arrays: Binary Search Approach

easy

How to solve LeetCode 1385 Find the Distance Value Between Two Arrays using sorting and binary search.

6 min
arraysbinary-search

Find the City With the Smallest Number of Neighbors at a Threshold Distance

medium

How to solve LeetCode 1334 using Floyd-Warshall shortest paths. Compute all-pairs shortest paths, then count reachable cities within the distance threshold.

6 min
graphdynamic-programming

Find a Corresponding Node of a Binary Tree in a Clone of That Tree

easy

How to solve LeetCode 1379 by traversing both trees simultaneously. The parallel DFS pattern explained with visual walkthroughs.

6 min
trees

Filter Restaurants by Vegan-Friendly, Price and Distance

medium

How to solve LeetCode 1333 Filter Restaurants by Vegan-Friendly, Price and Distance using filtering and custom sorting. Apply criteria then sort by rating and id.

5 min
arrayssorting

Design a Stack With Increment Operation: Lazy Propagation Pattern

medium

How to solve LeetCode 1381 Design a Stack With Increment Operation using a lazy increment array. The deferred computation pattern explained with visual walkthroughs.

7 min
arraysstacks

Delete Leaves With a Given Value: Recursive Tree Pruning

medium

How to solve LeetCode 1325 Delete Leaves With a Given Value using post-order traversal. Recursive tree pruning explained with visual walkthroughs.

5 min
trees

Count Negative Numbers in a Sorted Matrix

easy

How to solve LeetCode 1351 Count Negative Numbers in a Sorted Matrix. Use the staircase traversal pattern to count negatives in O(m + n) time.

6 min
arraysbinary-search

Count All Valid Pickup and Delivery Options: Combinatorial Counting Pattern

hard

How to solve LeetCode 1359 Count All Valid Pickup and Delivery Options using combinatorial math. Build the answer incrementally by inserting each new order into the sequence.

5 min
mathdynamic-programming

Convert Integer to the Sum of Two No-Zero Integers

easy

How to solve LeetCode 1317 Convert Integer to the Sum of Two No-Zero Integers. A simple math problem explained with visual diagrams.

4 min
math

Construct Target Array With Multiple Sums: Reverse Simulation with Max-Heap

hard

How to solve LeetCode 1354 Construct Target Array With Multiple Sums using reverse simulation with a max-heap. Visual walkthrough and Python solution.

7 min
arraysheap

Closest Divisors: Factor Pairs Nearest the Square Root

medium

How to solve LeetCode 1362 Closest Divisors. The factor pair closest to the square root always has the smallest difference.

6 min
math

Cinema Seat Allocation: Greedy Group Placement

medium

How to solve LeetCode 1386 Cinema Seat Allocation using bitmask or set-based greedy checking of group placements.

5 min
arrayshash-map

Check If N and Its Double Exist: Hash Set Lookup

easy

How to solve LeetCode 1346 Check If N and Its Double Exist. Use a hash set to find pairs where one element is twice another in O(n) time.

5 min
arrayshash-map

Break a Palindrome: Greedy Character Replacement

medium

How to solve LeetCode 1328 Break a Palindrome using greedy character replacement. Find the lexicographically smallest non-palindrome with one change.

5 min
stringsgreedy

Balance a Binary Search Tree: Inorder + Rebuild

medium

How to solve LeetCode 1382 Balance a Binary Search Tree using inorder traversal and divide-and-conquer rebuild.

6 min
treesgreedy

Apply Discount Every n Orders: Design with Hash Map

medium

How to solve LeetCode 1357 Apply Discount Every n Orders using a hash map for price lookup and a counter for discount tracking. Visual walkthrough and Python solution.

5 min
designarrays

Angle Between Hands of a Clock: Simple Math

medium

How to solve LeetCode 1344 Angle Between Hands of a Clock. Calculate the positions of both hands and find the smaller angle between them.

4 min
math

XOR Queries of a Subarray: Prefix XOR Pattern

medium

How to solve LeetCode 1310 XOR Queries of a Subarray using prefix XOR. The prefix computation pattern explained with visual walkthroughs.

4 min
arraysbit-manipulation

Unique Number of Occurrences: Hash Map Frequency Counting

easy

How to solve LeetCode 1207 Unique Number of Occurrences using a hash map and a set. Count frequencies and check uniqueness in one clean pass.

4 min
arrayshash-map

Ugly Number III: Binary Search and Inclusion-Exclusion

medium

How to solve LeetCode 1201 Ugly Number III using binary search with the inclusion-exclusion principle. Find the nth number divisible by a, b, or c.

7 min
mathbinary-search

Sum of Mutated Array Closest to Target: Binary Search on Answer

medium

How to solve LeetCode 1300 Sum of Mutated Array Closest to Target using binary search on the cap value. The binary search on answer pattern explained.

6 min
arraysbinary-search

Subtract the Product and Sum of Digits of an Integer

easy

How to solve LeetCode 1281 Subtract the Product and Sum of Digits. Extract digits with mod and div, compute the product and sum, then return the difference.

5 min
math

Split a String in Balanced Strings: Greedy Balance Counter

easy

How to solve LeetCode 1221 Split a String in Balanced Strings using a greedy approach. The balance counter pattern explained with visual walkthroughs.

4 min
stringsgreedy

Sort Items by Groups Respecting Dependencies: Double Topological Sort

hard

How to solve LeetCode 1203 Sort Items by Groups Respecting Dependencies using two-level topological sorting. A hard graph problem broken into manageable pieces.

7 min
graphsorting

Smallest String With Swaps: Union-Find for Connected Components

medium

How to solve LeetCode 1202 Smallest String With Swaps using Union-Find. Group indices by connectivity, sort within groups, and build the smallest string.

6 min
stringsgraph

Shortest Path in a Grid with Obstacles Elimination: BFS with State

hard

How to solve LeetCode 1293 Shortest Path in a Grid with Obstacles Elimination using BFS with an extra state dimension. Visual walkthrough of the (row, col, remaining_eliminations) approach.

8 min
arraysgraph

Shift 2D Grid: Flatten, Rotate, Reshape

easy

How to solve LeetCode 1260 Shift 2D Grid using the flatten-rotate-reshape pattern. A simulation problem explained with visual walkthroughs.

5 min
arraysmatrix

Sequential Digits: Generating Numbers with Consecutive Digits

medium

How to solve LeetCode 1291 Sequential Digits. Enumerate all numbers where each digit is exactly one more than the previous, filter by range, and return them sorted.

5 min
math

Search Suggestions System: Trie Meets Binary Search

medium

How to solve LeetCode 1268 Search Suggestions System using sorting with binary search or a trie. Visual walkthrough of prefix matching.

7 min
stringstrie

Replace the Substring for Balanced String: Sliding Window Pattern

medium

How to solve LeetCode 1234 Replace the Substring for Balanced String using sliding window. The minimum window pattern explained with visual walkthroughs.

6 min
stringssliding-window

Replace Elements with Greatest Element on Right Side: Right-to-Left Scan

easy

How to solve LeetCode 1299 Replace Elements with Greatest Element on Right Side using a right-to-left scan with running maximum.

5 min
arrays

Remove Sub-Folders from the Filesystem: Sort and Prefix Check

medium

How to solve LeetCode 1233 Remove Sub-Folders from the Filesystem using sorting and prefix checking. The pattern explained with visual walkthroughs.

4 min
arraysstrings

Remove Covered Intervals: Sort and Count

medium

How to solve LeetCode 1288 Remove Covered Intervals with sorting and a greedy scan. Walk through the approach, Python solution, edge cases, and the building blocks you can reuse.

6 min
arrayssorting

Remove All Adjacent Duplicates in String II: Stack-Based Character Counting

medium

How to solve LeetCode 1209 Remove All Adjacent Duplicates in String II using a stack with character counts.

5 min
stringsstacks

Queens That Can Attack the King: Direction Scanning

medium

How to solve LeetCode 1222 Queens That Can Attack the King using direction scanning from the king. The 8-direction search pattern explained with visual walkthroughs.

5 min
arraysmatrix

Path with Maximum Gold: Backtracking on a Grid

medium

How to solve LeetCode 1219 Path with Maximum Gold using backtracking. The grid DFS pattern explained with visual walkthroughs.

7 min
arraysbacktracking

Palindrome Partitioning III: Minimum Changes to Split into K Palindromes

hard

How to solve LeetCode 1278 Palindrome Partitioning III with dynamic programming. Visual walkthrough of the two-layer DP approach.

7 min
stringsdynamic-programming

Number of Ways to Stay in the Same Place After Some Steps

hard

How to solve LeetCode 1269 with dynamic programming. Visual DP table walkthrough for counting paths that return to index 0.

6 min
dynamic-programming

Number of Closed Islands: DFS Boundary Elimination

medium

How to solve LeetCode 1254 Number of Closed Islands using DFS boundary elimination. A grid traversal pattern explained with visual walkthroughs.

6 min
arraysgraph

Minimum Remove to Make Valid Parentheses: Stack Index Pattern

medium

How to solve LeetCode 1249 Minimum Remove to Make Valid Parentheses using a stack to track unmatched indices.

5 min
stringsstacks

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix

hard

How to solve LeetCode 1284 using BFS on bitmask states. Visual walkthrough of encoding a matrix as a bitmask and searching for the shortest flip sequence to reach all zeros.

6 min
arraysmatrix

Minimum Moves to Reach Target with Rotations: BFS on State Space

hard

How to solve LeetCode 1210 Minimum Moves to Reach Target with Rotations using BFS with (row, col, orientation) states.

8 min
graphmatrix

Minimum Insertion Steps to Make a String Palindrome

hard

How to solve LeetCode 1312 Minimum Insertion Steps to Make a String Palindrome using dynamic programming. The longest palindromic subsequence approach explained with visual walkthroughs.

5 min
stringsdynamic-programming

Minimum Falling Path Sum II: Multi-Column DP

hard

How to solve LeetCode 1289 Minimum Falling Path Sum II using dynamic programming with a two-minimum optimization. Reduce from O(n^3) to O(n^2) by tracking the smallest and second-smallest values in each row.

6 min
arraysdynamic-programming

Minimum Cost to Move Chips: The Parity Trick

easy

How to solve LeetCode 1217 Minimum Cost to Move Chips to The Same Position by counting odd and even positions.

5 min
arraysmath

Minimum Absolute Difference: Sorting and Adjacent Pairs

easy

How to solve LeetCode 1200 Minimum Absolute Difference using sorting and a single pass. The adjacent-pair pattern explained with visual walkthroughs.

5 min
arrayssorting

Maximum Score Words Formed by Letters: Backtracking with Letter Budgets

hard

How to solve LeetCode 1255 Maximum Score Words Formed by Letters using backtracking with frequency counting. A subset exploration pattern explained with visual walkthroughs.

6 min
arraysstrings

Maximum Profit in Job Scheduling: DP with Binary Search

hard

How to solve LeetCode 1235 Maximum Profit in Job Scheduling using dynamic programming with binary search. The weighted interval scheduling pattern explained with visuals.

5 min
arraysbinary-search

Maximum Number of Occurrences of a Substring: Sliding Window with Frequency Map

medium

How to solve LeetCode 1297 Maximum Number of Occurrences of a Substring using sliding window and hash map counting.

5 min
stringshash-map

Maximum Length of Concatenated String: Backtracking with Bitmasks

medium

How to solve LeetCode 1239 Maximum Length of a Concatenated String with Unique Characters using backtracking and bitmask character sets.

7 min
arraysstrings

Maximum Candies You Can Get from Boxes: BFS Simulation

hard

How to solve LeetCode 1298 Maximum Candies You Can Get from Boxes using BFS simulation with key and box tracking.

7 min
arraysgraph

Longest Arithmetic Subsequence of Given Difference: Hash Map DP

medium

How to solve LeetCode 1218 Longest Arithmetic Subsequence of Given Difference using dynamic programming with a hash map.

6 min
arrayshash-map

Jump Game III: BFS Reachability Check

medium

How to solve LeetCode 1306 Jump Game III using BFS to check if you can reach an index with value 0. Graph traversal on an array.

6 min
arraysgraph

Iterator for Combination: Design Meets Backtracking

medium

How to solve LeetCode 1286 Iterator for Combination by pre-generating sorted combinations with backtracking and serving them through a pointer-based iterator. Walkthrough, complexity, and building blocks.

6 min
stringsbacktracking

Group the People Given the Group Size They Belong To: Hash Map Bucketing

medium

How to solve LeetCode 1282 in O(n) using a hash map to bucket people by group size. Visual step-by-step walkthrough with Python solution.

5 min
arrayshash-map

Greatest Sum Divisible by Three: Remainder DP Pattern

medium

How to solve LeetCode 1262 Greatest Sum Divisible by Three using dynamic programming with remainder tracking. A modular arithmetic DP pattern explained with visual walkthroughs.

6 min
dynamic-programminggreedy

Get Watched Videos by Your Friends: BFS + Frequency Counting

medium

How to solve LeetCode 1311 Get Watched Videos by Your Friends using BFS and hash map frequency counting. Graph traversal meets sorting explained with visual walkthroughs.

5 min
arrayshash-map

Get Equal Substrings Within Budget: Sliding Window Cost Control

medium

How to solve LeetCode 1208 Get Equal Substrings Within Budget using a sliding window over character costs.

5 min
stringsbinary-search

Find Winner on a Tic Tac Toe Game: Simulation Made Simple

easy

How to solve LeetCode 1275 Find Winner on a Tic Tac Toe Game. Track row, column, and diagonal sums to detect a winner without scanning the board.

6 min
arraysmatrix

Find the Smallest Divisor Given a Threshold

medium

How to solve LeetCode 1283 by binary searching the divisor. The monotonic relationship between divisor size and sum makes this a classic search-on-answer problem.

6 min
arraysbinary-search

Find Positive Integer Solution: Two-Pointer Search Pattern

medium

How to solve LeetCode 1237 Find Positive Integer Solution for a Given Equation using two pointers on a monotonic function.

6 min
mathbinary-search

Find Numbers with Even Number of Digits: Digit Counting

easy

How to solve LeetCode 1295 Find Numbers with Even Number of Digits using digit counting. A clean array filtering approach.

5 min
arrays

Find N Unique Integers Sum up to Zero: Symmetric Pairs

easy

How to solve LeetCode 1304 Find N Unique Integers Sum up to Zero using symmetric pair generation. A clean math-based approach.

4 min
arraysmath

Find Elements in a Contaminated Binary Tree: DFS Recovery with Hash Set

medium

How to solve LeetCode 1261 Find Elements in a Contaminated Binary Tree using DFS recovery and hash set lookup. A tree traversal pattern explained with visual walkthroughs.

6 min
treeshash-map

Divide Array in Sets of K Consecutive Numbers: Greedy Grouping

medium

How to solve LeetCode 1296 Divide Array in Sets of K Consecutive Numbers using greedy grouping with a frequency map.

5 min
arrayshash-map

Dice Roll Simulation: Constrained DP

hard

How to solve LeetCode 1223 Dice Roll Simulation using dynamic programming with consecutive count tracking. The constrained state DP pattern explained with visual walkthroughs.

6 min
dynamic-programming

Deepest Leaves Sum: BFS Level-by-Level Traversal

medium

How to solve LeetCode 1302 Deepest Leaves Sum using BFS level-order traversal. Track the last level and sum its values.

6 min
trees

Decrypt String from Alphabet to Integer Mapping

easy

How to solve LeetCode 1309 Decrypt String from Alphabet to Integer Mapping. A clean string parsing approach explained with visual diagrams.

5 min
strings

Decompress Run-Length Encoded List

easy

How to solve LeetCode 1313 Decompress Run-Length Encoded List. A simple array iteration pattern explained with visual diagrams.

4 min
arrays

Count Vowels Permutation: State Machine DP

hard

How to solve LeetCode 1220 Count Vowels Permutation using dynamic programming with state transitions. The vowel transition pattern explained with visual walkthroughs.

6 min
dynamic-programming

Count Square Submatrices with All Ones: DP on a Grid

medium

How to solve LeetCode 1277 Count Square Submatrices with All Ones using dynamic programming. Visual grid walkthrough of the min-of-neighbors pattern.

6 min
arraysdynamic-programming

Count Number of Nice Subarrays: Prefix Count Pattern

medium

How to solve LeetCode 1248 Count Number of Nice Subarrays using prefix odd counts and a hash map to count subarrays with exactly k odd numbers.

6 min
arrayshash-map

Convert Binary Number in a Linked List to Integer

easy

How to solve LeetCode 1290: traverse a linked list of binary digits and convert to decimal using the shift-and-add technique. Visual walkthrough with Python solution.

4 min
linked-listsmath

Check If It Is a Straight Line: Cross Multiplication Pattern

easy

How to solve LeetCode 1232 Check If It Is a Straight Line using cross multiplication to avoid division. The collinearity check explained with visuals.

6 min
arraysmath

Cells with Odd Values in a Matrix: Row and Column Parity

easy

How to solve LeetCode 1252 Cells with Odd Values in a Matrix by counting row and column increment parities instead of simulating.

6 min
arraysmath

All Elements in Two Binary Search Trees: Inorder Merge

medium

How to solve LeetCode 1305 All Elements in Two Binary Search Trees using inorder traversal and merge. Combine BST properties with the merge step from merge sort.

5 min
treessorting

Airplane Seat Assignment Probability: Mathematical Insight

medium

How to solve LeetCode 1227 Airplane Seat Assignment Probability using mathematical reasoning. The probability pattern explained with visual walkthroughs.

6 min
mathdynamic-programming

Stone Game II: Minimax Dynamic Programming

medium

How to solve LeetCode 1140 Stone Game II using suffix sums and memoized recursion. Visual walkthrough of the (index, M) state space with Python solution.

6 min
arraysdynamic-programming

Statistics from a Large Sample: Frequency Array Analysis

medium

How to solve LeetCode 1093 Statistics from a Large Sample using frequency counting. Compute min, max, mean, median, and mode from a count array.

5 min
math

Snapshot Array: Versioned Data with Binary Search

medium

How to solve LeetCode 1146 Snapshot Array using hash maps and binary search. Build a versioned array that supports efficient snapshots.

7 min
arrayshash-map

Smallest Sufficient Team: Bitmask DP Pattern

hard

How to solve LeetCode 1125 Smallest Sufficient Team using bitmask dynamic programming. Track skill coverage with bits and find the minimum team.

6 min
dynamic-programmingbit-manipulation

Smallest Subsequence of Distinct Characters: Monotonic Stack Pattern

medium

How to solve LeetCode 1081 Smallest Subsequence of Distinct Characters using a monotonic stack with greedy removal. Visual walkthrough and clean Python code.

6 min
stringsstacks

Shortest Path with Alternating Colors: Modified BFS Pattern

medium

How to solve LeetCode 1129 Shortest Path with Alternating Colors using BFS with state tracking. Learn the constrained BFS pattern for graph problems.

8 min
graph

Shortest Path in Binary Matrix: 8-Directional BFS

medium

How to solve LeetCode 1091 Shortest Path in Binary Matrix using BFS with 8-directional movement. Visual walkthrough and clean Python code.

7 min
arraysmatrix

Shortest Common Supersequence: LCS-Based String Construction

hard

How to solve LeetCode 1092 Shortest Common Supersequence using LCS dynamic programming with backtracking. Visual walkthrough and clean Python code.

6 min
stringsdynamic-programming

Reverse Substrings Between Each Pair of Parentheses: Inside-Out Stack Pattern

medium

How to solve LeetCode 1190 Reverse Substrings Between Each Pair of Parentheses using a stack. Process nested parentheses from the inside out with a clean push-and-reverse approach.

6 min
stringsstacks

Relative Sort Array: Custom Ordering with Counting

easy

How to solve LeetCode 1122 Relative Sort Array using counting sort and hash maps. Sort one array based on the ordering defined by another.

6 min
arrayshash-map

Print in Order: Thread Synchronization with Barriers

easy

How to solve LeetCode 1114 Print in Order using threading barriers and events. Learn thread synchronization patterns for coding interviews.

5 min
design

Prime Arrangements: Counting Permutations of Primes and Composites

easy

How to solve LeetCode 1175 Prime Arrangements by counting primes up to n and multiplying factorials of prime and non-prime counts.

5 min
math

Previous Permutation With One Swap: Greedy Array Strategy

medium

How to solve LeetCode 1053 Previous Permutation With One Swap using a greedy approach. Find the largest permutation smaller than the current one with a single swap.

5 min
arraysgreedy

Path In Zigzag Labelled Binary Tree: Mirror Math

medium

How to solve LeetCode 1104 Path In Zigzag Labelled Binary Tree. Use bit-length to find the level, mirror the label within the level to undo zigzag reversal, and divide by 2 to climb to the parent.

7 min
mathtrees

Occurrences After Bigram: Linear Scan Pattern

easy

How to solve LeetCode 1078 Occurrences After Bigram with a simple linear scan. String matching with sliding window of words explained visually.

5 min
strings

Number of Valid Words for Each Puzzle: Bitmask Subset Enumeration

hard

How to solve LeetCode 1178 Number of Valid Words for Each Puzzle using bitmask representation and subset enumeration to efficiently match words to puzzles.

6 min
stringshash-map

Number of Submatrices That Sum to Target: 2D Prefix Sums

hard

How to solve LeetCode 1074 Number of Submatrices That Sum to Target using prefix sums and hash maps. The 2D subarray sum pattern explained visually.

7 min
arrayshash-map

Number of Equivalent Domino Pairs: Counting with Normalization

easy

How to solve LeetCode 1128 Number of Equivalent Domino Pairs using hash map counting with key normalization. A clean pattern for equivalence problems.

6 min
arrayshash-map

Number of Dice Rolls With Target Sum: DP on Dice

medium

How to solve LeetCode 1155 Number of Dice Rolls With Target Sum using dynamic programming. Count the ways to roll n dice with k faces to reach a target sum.

7 min
dynamic-programming

N-th Tribonacci Number: Dynamic Programming Fundamentals

easy

How to solve LeetCode 1137 N-th Tribonacci Number using bottom-up dynamic programming with O(n) time and O(1) space. Visual walkthrough of the rolling window approach.

5 min
dynamic-programmingmath

Minimum Cost Tree From Leaf Values: Monotonic Stack Pattern

medium

How to solve LeetCode 1130 Minimum Cost Tree From Leaf Values using a monotonic stack. Reduce tree construction to a greedy pairing problem.

7 min
arraysstacks

Maximum of Absolute Value Expression: Sign Expansion Pattern

medium

How to solve LeetCode 1131 Maximum of Absolute Value Expression by expanding absolute values into sign combinations. A clean math optimization trick.

7 min
arraysmath

Maximum Number of Balloons: Hash Map Frequency Counting

easy

How to solve LeetCode 1189 Maximum Number of Balloons using hash map frequency counting. Count characters, divide by what each balloon needs, and take the minimum.

5 min
stringshash-map

Maximum Nesting Depth of Two Valid Parentheses Strings: Depth-Based Splitting

medium

How to solve LeetCode 1111 Maximum Nesting Depth of Two Valid Parentheses Strings using depth parity. Split parentheses to minimize max depth with a clean greedy approach.

6 min
stringsstacks

Maximum Level Sum of a Binary Tree: Level-Order BFS Pattern

medium

How to solve LeetCode 1161 Maximum Level Sum of a Binary Tree using level-order BFS. Track per-level sums with visual walkthroughs.

6 min
trees

Lowest Common Ancestor of Deepest Leaves: Recursive Depth Comparison

medium

How to solve LeetCode 1123 Lowest Common Ancestor of Deepest Leaves using recursive DFS. Find the LCA by comparing subtree depths.

5 min
trees

Longest Well-Performing Interval: Prefix Sum with Hash Map

medium

How to solve LeetCode 1124 Longest Well-Performing Interval using prefix sums and hash maps. Transform the problem into finding the longest subarray with positive sum.

6 min
arrayshash-map

Longest Chunked Palindrome Decomposition: Greedy Matching

hard

How to solve LeetCode 1147 Longest Chunked Palindrome Decomposition using greedy two-pointer matching. Break a string into the maximum number of palindromic chunks.

6 min
stringsgreedy

Letter Tile Possibilities: Counting with Backtracking

medium

How to solve LeetCode 1079 Letter Tile Possibilities using backtracking with frequency counting. Generate all unique non-empty sequences explained visually.

6 min
stringsbacktracking

Last Substring in Lexicographical Order: Two-Pointer Suffix Comparison

hard

How to solve LeetCode 1163 Last Substring in Lexicographical Order using a two-pointer approach. Find the lexicographically largest suffix in O(n) time.

5 min
stringstwo-pointers

Largest Values From Labels: Greedy Selection with Constraints

medium

How to solve LeetCode 1090 Largest Values From Labels using greedy sorting with label frequency limits. Visual walkthrough and clean Python code.

6 min
arraysgreedy

Largest 1-Bordered Square: Prefix Sum on a Grid

medium

How to solve LeetCode 1139 Largest 1-Bordered Square by precomputing horizontal and vertical consecutive-ones counts and verifying square borders efficiently.

7 min
arraysdynamic-programming

K-Concatenation Maximum Sum: Extending Kadane's to Repeated Arrays

medium

How to solve LeetCode 1191 K-Concatenation Maximum Sum using Kadane's algorithm with prefix and suffix sums. Handle repeated arrays in O(n) time.

6 min
dynamic-programming

Invalid Transactions: Hash Map Grouping Pattern

medium

How to solve LeetCode 1169 Invalid Transactions using hash map grouping and pairwise comparison. Parse, group, and validate transactions with visual walkthroughs.

6 min
arraysstrings

Insufficient Nodes in Root to Leaf Paths: Tree Pruning with DFS

medium

How to solve LeetCode 1080 Insufficient Nodes in Root to Leaf Paths using recursive DFS. Tree pruning pattern explained with visual diagrams.

6 min
trees

Grumpy Bookstore Owner: Sliding Window Technique

medium

How to solve LeetCode 1052 Grumpy Bookstore Owner using the sliding window pattern. Maximize customer satisfaction by choosing the optimal window.

7 min
arrayssliding-window

Greatest Common Divisor of Strings: GCD Pattern

easy

How to solve LeetCode 1071 Greatest Common Divisor of Strings using the GCD pattern. Find the largest string that divides both input strings.

6 min
stringsmath

Flip Columns For Maximum Number of Equal Rows: Pattern Matching in Matrices

medium

How to solve LeetCode 1072 Flip Columns For Maximum Number of Equal Rows using row pattern normalization. Group rows by their canonical form to find the answer.

6 min
arrayshash-map

Find Words That Can Be Formed by Characters: Character Frequency Pattern

easy

How to solve LeetCode 1160 Find Words That Can Be Formed by Characters using character frequency counting. Hash map counting pattern explained with visual walkthroughs.

5 min
arraysstrings

Find in Mountain Array: Triple Binary Search

hard

How to solve LeetCode 1095 Find in Mountain Array using three binary searches. Find the peak, then search ascending and descending halves.

6 min
arraysbinary-search

Filling Bookcase Shelves: Minimizing Height with DP

medium

How to solve LeetCode 1105 Filling Bookcase Shelves using dynamic programming. Visual shelf-packing walkthrough and clean Python solution.

5 min
dynamic-programming

Duplicate Zeros: In-Place Array Shifting

easy

How to solve LeetCode 1089 Duplicate Zeros by shifting elements in-place from right to left. Visual walkthrough and clean Python code.

6 min
arrays

Distribute Candies to People: Round-Robin Simulation

easy

How to solve LeetCode 1103 Distribute Candies to People using simulation. Distribute increasing amounts in a round-robin pattern.

5 min
mathsimulation

Distant Barcodes: Frequency-Based Greedy Rearrangement

medium

How to solve LeetCode 1054 Distant Barcodes using frequency counting and greedy placement. Rearrange elements so no two adjacent are equal.

6 min
arrayshash-map

Distance Between Bus Stops: Circular Array Minimum Path

easy

How to solve LeetCode 1184 Distance Between Bus Stops by computing clockwise distance and taking the minimum of both directions around the circular route.

5 min
arrays

Delete Nodes And Return Forest: Splitting a Tree with Post-Order DFS

medium

How to solve LeetCode 1110 Delete Nodes And Return Forest using post-order DFS, a hash set for deletions, and an is_root flag to collect the resulting forest.

7 min
treeshash-map

Defanging an IP Address: Simple String Replacement

easy

How to solve LeetCode 1108 Defanging an IP Address by replacing dots with [.]. Visual walkthrough with Python code and complexity analysis.

4 min
strings

Decrease Elements To Make Array Zigzag: Greedy Two-Pass Strategy

medium

How to solve LeetCode 1144 Decrease Elements To Make Array Zigzag with a greedy approach. Try both zigzag patterns, compute the cost of each, and return the minimum.

7 min
arraysgreedy

Day of the Year: Date Parsing and Leap Year Logic

easy

How to solve LeetCode 1154 Day of the Year using date parsing and prefix sums of month lengths. Handle leap years correctly.

6 min
mathstrings

Day of the Week: Zeller's Congruence in Code

easy

How to solve LeetCode 1185 Day of the Week using Zeller's congruence. A clean formula maps any date to its weekday in O(1) time.

6 min
math

Critical Connections in a Network: Tarjan's Bridge-Finding Algorithm

hard

How to solve LeetCode 1192 Critical Connections in a Network using Tarjan's algorithm. Find bridges in an undirected graph with DFS, discovery times, and low-link values.

7 min
graph

Corporate Flight Bookings: Difference Array for Range Updates

medium

How to solve LeetCode 1109 Corporate Flight Bookings using a difference array and prefix sum. Efficiently apply range updates to compute total seats per flight.

6 min
arrays

Compare Strings by Frequency of the Smallest Character: Binary Search on Sorted Counts

medium

How to solve LeetCode 1170 Compare Strings by Frequency of the Smallest Character using sorted frequency arrays and binary search.

5 min
arraysstrings

Car Pooling: Difference Array Sweep Line

medium

How to solve LeetCode 1094 Car Pooling using a difference array and sweep line. Track passenger counts at each stop efficiently.

6 min
arrayssorting

Can Make Palindrome from Substring: Prefix XOR for Character Parity

medium

How to solve LeetCode 1177 Can Make Palindrome from Substring using prefix XOR bitmasks to count odd-frequency characters in any substring in O(1).

5 min
stringshash-map

Brace Expansion II: Recursive Set Operations

hard

How to solve LeetCode 1096 Brace Expansion II using a stack-based parser with union and concatenation of string sets.

6 min
stringsstacks

Binary Tree Coloring Game: Counting Subtree Sizes

medium

How to solve LeetCode 1145 Binary Tree Coloring Game using subtree counting. Determine if player 2 can always win by choosing the right adjacent node.

7 min
trees

As Far from Land as Possible: Multi-Source BFS Pattern

medium

How to solve LeetCode 1162 As Far from Land as Possible using multi-source BFS. Find maximum Manhattan distance from any water cell to nearest land.

7 min
arraysmatrix

Alphabet Board Path: Grid Coordinate Navigation

medium

How to solve LeetCode 1138 Alphabet Board Path using coordinate mapping and careful handling of the letter 'z'. The grid navigation pattern explained.

6 min
stringshash-map

Adding Two Negabinary Numbers: Base -2 Arithmetic

medium

How to solve LeetCode 1073 Adding Two Negabinary Numbers. Learn base -2 addition with carry handling, explained with visual diagrams.

7 min
math

Video Stitching: Greedy Interval Coverage Pattern

medium

How to solve LeetCode 1024 Video Stitching using a greedy interval approach. Cover a target range [0, time] with the minimum number of clips.

5 min
arraysgreedy

Valid Boomerang: Cross Product for Collinearity

easy

How to solve LeetCode 1037 Valid Boomerang using the cross product to check whether three points are collinear. A clean geometry pattern explained with visual walkthroughs.

5 min
math

Uncrossed Lines: LCS in Disguise

medium

How to solve LeetCode 1035 Uncrossed Lines with 2D DP. This problem is the Longest Common Subsequence pattern applied to two integer arrays.

5 min
arraysdynamic-programming

Two City Scheduling: Greedy Cost Optimization

medium

How to solve LeetCode 1029 Two City Scheduling using a greedy sorting approach. Minimize total cost by sorting on the savings of choosing one city over another.

6 min
arraysgreedy

Sum of Root To Leaf Binary Numbers: Tree DFS Pattern

easy

How to solve LeetCode 1022 Sum of Root To Leaf Binary Numbers using DFS with bit manipulation. Build binary numbers along root-to-leaf paths.

6 min
trees

Sum of Root To Leaf Binary Numbers: DFS Binary Accumulation

easy

How to solve LeetCode 1022 Sum of Root To Leaf Binary Numbers using DFS traversal. Build each binary number as you walk from root to leaf, accumulating the value with current_sum * 2 + node.val at each step.

7 min
trees

Subarrays with K Different Integers: The At-Most Trick

hard

How to solve LeetCode 992 Subarrays with K Different Integers. Use the at-most sliding window technique to count subarrays with exactly k distinct values.

5 min
arrayshash-map

Stream of Characters: Reverse Trie for Suffix Matching

hard

How to solve LeetCode 1032 Stream of Characters using a reverse trie. Insert words backwards and search from the end of the stream buffer.

7 min
triedesign

Smallest Integer Divisible by K: Remainder Cycle Detection

medium

How to solve LeetCode 1015 Smallest Integer Divisible by K using modular arithmetic and cycle detection. The remainder tracking pattern explained with visual walkthroughs.

6 min
mathhash-map

Satisfiability of Equality Equations: Union-Find for Variable Constraints

medium

How to solve LeetCode 990 Satisfiability of Equality Equations. Use union-find to group equal variables, then check inequality constraints for contradictions.

5 min
graphstrings

Rotting Oranges: Multi-Source BFS Pattern

medium

How to solve LeetCode 994 Rotting Oranges using multi-source BFS. The grid BFS pattern explained with visual walkthroughs.

7 min
arraysmatrix

Robot Bounded In Circle: Simulation and Direction Vectors

medium

How to solve LeetCode 1041 Robot Bounded In Circle using direction simulation. The direction vector pattern explained with visual walkthroughs.

6 min
mathstrings

Remove Outermost Parentheses: Depth Counter Pattern

easy

How to solve LeetCode 1021 Remove Outermost Parentheses using a depth counter. A clean pattern for identifying nesting levels in parentheses strings.

5 min
stringsstacks

Remove All Adjacent Duplicates In String: Stack Pattern

easy

How to solve LeetCode 1047 Remove All Adjacent Duplicates In String using a stack. The stack-based duplicate removal pattern explained with visual walkthroughs.

5 min
stringsstacks

Recover a Tree From Preorder Traversal: Stack-Based Tree Construction

hard

How to solve LeetCode 1028 Recover a Tree From Preorder Traversal using a stack. Parse a dash-encoded preorder string to rebuild the binary tree.

7 min
treesstrings

Partition Array Into Three Parts With Equal Sum: Greedy Prefix Scan

easy

How to solve LeetCode 1013 Partition Array Into Three Parts With Equal Sum using a greedy prefix sum approach in O(n) time.

7 min
arraysgreedy

Partition Array for Maximum Sum: DP with Partition Choices

medium

How to solve LeetCode 1043 Partition Array for Maximum Sum using dynamic programming. The partition DP pattern explained with visual walkthroughs.

5 min
arraysdynamic-programming

Pairs of Songs With Total Durations Divisible by 60: Remainder Counting

medium

How to solve LeetCode 1010 Pairs of Songs With Total Durations Divisible by 60 using a remainder hash map in O(n) time.

9 min
arrayshash-map

Online Stock Span: Monotonic Stack Pattern

medium

How to solve LeetCode 901 Online Stock Span using a monotonic decreasing stack. Step-by-step visual walkthrough of the span calculation.

6 min
stacks

Numbers At Most N Given Digit Set: Digit DP Pattern

hard

How to solve LeetCode 902 Numbers At Most N Given Digit Set using digit dynamic programming. Count valid numbers digit by digit with visual walkthrough.

7 min
mathdynamic-programming

Number of Squareful Arrays: Backtracking with Graph Modeling

hard

How to solve LeetCode 996 Number of Squareful Arrays using backtracking and graph adjacency. Explained with visual walkthroughs.

6 min
arraysbacktracking

Number of Enclaves: Border-Connected Flood Fill

medium

How to solve LeetCode 1020 Number of Enclaves using border-connected DFS to eliminate reachable land cells. The boundary flood fill pattern explained with visual walkthroughs.

8 min
arraysgraph

Next Greater Node In Linked List: Monotonic Stack on Lists

medium

How to solve LeetCode 1019 Next Greater Node In Linked List using a monotonic stack. The next greater element pattern applied to linked lists, explained with visual walkthroughs.

7 min
linked-listsstacks

Moving Stones Until Consecutive II: Sliding Window on Sorted Endpoints

medium

How to solve LeetCode 1040 Moving Stones Until Consecutive II using sliding window and greedy endpoints. The sorted window pattern explained with visual walkthroughs.

7 min
arraysmath

Minimum Score Triangulation of Polygon: Interval DP on Shapes

medium

How to solve LeetCode 1039 Minimum Score Triangulation of Polygon using interval DP. Break a convex polygon into triangles by choosing pivot vertices, just like matrix chain multiplication.

5 min
dynamic-programming

Minimum Number of K Consecutive Bit Flips: Greedy Sliding Window

hard

How to solve LeetCode 995 Minimum Number of K Consecutive Bit Flips using a greedy approach with a sliding window. Explained with visual walkthroughs.

6 min
arraysbit-manipulation

Minimum Domino Rotations For Equal Row: Greedy Candidate Check

medium

How to solve LeetCode 1007 Minimum Domino Rotations For Equal Row using a greedy approach. Check candidate values and count minimum swaps.

6 min
arraysgreedy

Minimum Cost to Merge Stones: Interval DP

hard

How to solve LeetCode 1000 Minimum Cost to Merge Stones using interval DP with prefix sums. Learn when merging is possible, how to structure the recurrence, and why you only add the merge cost at the right moment.

6 min
dynamic-programming

Maximum Sum of Two Non-Overlapping Subarrays: Prefix Sum + Sliding Window

medium

How to solve LeetCode 1031 Maximum Sum of Two Non-Overlapping Subarrays using prefix sums and a running maximum. Track the best first window as you slide the second.

6 min
arraysdynamic-programming

Maximum Difference Between Node and Ancestor: Tree Min/Max Tracking

medium

How to solve LeetCode 1026 Maximum Difference Between Node and Ancestor using DFS with min/max tracking. Find the largest |ancestor - descendant| difference.

7 min
trees

Maximum Binary Tree II: Rightmost Path Insertion

medium

How to solve LeetCode 998 Maximum Binary Tree II by walking the rightmost path. Tree insertion pattern explained with visual walkthroughs.

6 min
trees

Maximize Sum Of Array After K Negations: Greedy Sorting Pattern

easy

How to solve LeetCode 1005 Maximize Sum Of Array After K Negations using a greedy approach with sorting. Negate the smallest elements first to maximize the total sum.

5 min
arraysgreedy

Max Consecutive Ones III: Sliding Window with Flips

medium

How to solve LeetCode 1004 Max Consecutive Ones III using the sliding window pattern. Track flipped zeros and maintain the longest window of consecutive ones.

6 min
arrayssliding-window

Matrix Cells in Distance Order: BFS Rings on a Grid

easy

How to solve LeetCode 1030 Matrix Cells in Distance Order using BFS or sorting by Manhattan distance. A clean introduction to distance-based grid traversal.

6 min
arraysmatrix

Longest String Chain: Hash Map DP Pattern

medium

How to solve LeetCode 1048 Longest String Chain using hash map dynamic programming. The word chain DP pattern explained with visual walkthroughs.

6 min
arrayshash-map

Longest Duplicate Substring: Binary Search and Rolling Hash

hard

How to solve LeetCode 1044 Longest Duplicate Substring using binary search on length with Rabin-Karp rolling hash. The binary search on answer pattern explained with visual walkthroughs.

6 min
stringsbinary-search

Longest Arithmetic Subsequence: DP with Hash Map Pattern

medium

How to solve LeetCode 1027 Longest Arithmetic Subsequence using dynamic programming with hash maps. Track the longest subsequence for each common difference.

6 min
arrayshash-map

Last Stone Weight: Max Heap Pattern

easy

How to solve LeetCode 1046 Last Stone Weight using a max heap. Learn the heap-based simulation pattern with visual walkthroughs.

6 min
arraysheap

Last Stone Weight II: Subset Sum DP Pattern

medium

How to solve LeetCode 1049 Last Stone Weight II using subset sum dynamic programming. The partition minimization pattern explained with visual walkthroughs.

6 min
dynamic-programming

Height Checker: Sort and Compare Pattern

easy

How to solve LeetCode 1051 Height Checker using sort and compare. The comparison counting pattern explained with visual walkthroughs.

5 min
arrayssorting

Grid Illumination: Hash Map Line Counting

hard

How to solve LeetCode 1001 Grid Illumination using hash maps to count lamps per row, column, and diagonal. Turn off neighbors efficiently with a lamp set.

8 min
arrayshash-map

Flower Planting With No Adjacent: Greedy Graph Coloring

medium

How to solve LeetCode 1042 Flower Planting With No Adjacent using greedy graph coloring. The constrained coloring pattern explained with visual walkthroughs.

5 min
graph

Find the Town Judge: Graph Degree Counting

easy

How to solve LeetCode 997 Find the Town Judge using in-degree and out-degree counting. The trust graph pattern explained.

5 min
arraysgraph

Find Common Characters: Frequency Intersection

easy

How to solve LeetCode 1002 Find Common Characters using character frequency counting and element-wise minimums. Step-by-step visual walkthrough.

5 min
arraysstrings

Divisor Game: Math Pattern Recognition

easy

How to solve LeetCode 1025 Divisor Game using mathematical insight. Determine the winner with a simple even/odd check.

6 min
mathdynamic-programming

Cousins in Binary Tree: Checking Depth and Parent with BFS

easy

How to solve LeetCode 993 Cousins in Binary Tree. Use BFS to find the depth and parent of two nodes, then check if they are cousins.

6 min
trees

Convert to Base -2: Negative Base Number Systems

medium

How to solve LeetCode 1017 Convert to Base -2 using modified division with remainder adjustment. Negative base conversion explained with visual walkthroughs.

6 min
math

Construct BST from Preorder Traversal: Upper Bound Recursion

medium

How to solve LeetCode 1008 Construct Binary Search Tree from Preorder Traversal using an upper bound recursive approach in O(n) time.

6 min
arraystrees

Complement of Base 10 Integer: Bit Flipping with XOR

easy

How to solve LeetCode 1009 Complement of Base 10 Integer using a bitmask and XOR in O(log n) time.

8 min
bit-manipulation

Coloring A Border: DFS Component Boundary Detection

medium

How to solve LeetCode 1034 Coloring A Border using DFS to find a connected component and identify its border cells. A practical grid traversal exercise.

7 min
arraysgraph

Clumsy Factorial: Stack-Based Expression Evaluation

medium

How to solve LeetCode 1006 Clumsy Factorial using a stack to evaluate expressions with rotating operations. Master the operator precedence pattern.

5 min
mathstacks

Check If Word Is Valid After Substitutions: Stack Reduction

medium

How to solve LeetCode 1003 Check If Word Is Valid After Substitutions using a stack. Visual walkthrough with Python code.

5 min
stringsstacks

Capacity To Ship Packages Within D Days: Binary Search on Answer

medium

How to solve LeetCode 1011 Capacity To Ship Packages Within D Days using binary search on the answer in O(n log S) time.

8 min
arraysbinary-search

Camelcase Matching: Two-Pointer String Pattern

medium

How to solve LeetCode 1023 Camelcase Matching using two pointers. Match patterns against camelCase strings by skipping lowercase insertions.

6 min
stringstrie

Broken Calculator: Working Backwards with Greedy Division

medium

How to solve LeetCode 991 Broken Calculator. Work backwards from target, dividing even numbers and adding 1 to odd numbers for a greedy solution.

5 min
mathgreedy

Binary Search Tree to Greater Sum Tree

medium

How to solve LeetCode 1038 Binary Search Tree to Greater Sum Tree. Use reverse inorder traversal with a running sum to convert each node's value in-place.

6 min
trees

Binary Prefix Divisible By 5: Running Remainder Pattern

easy

How to solve LeetCode 1018 Binary Prefix Divisible By 5 using running modular arithmetic. The prefix remainder pattern explained with visual walkthroughs.

6 min
arrays

Best Sightseeing Pair: Decomposing the Score Formula

medium

How to solve LeetCode 1014 Best Sightseeing Pair by decomposing the score into two independent terms in O(n) time.

8 min
arraysdynamic-programming

Available Captures for Rook: Direct Simulation

easy

How to solve LeetCode 999 Available Captures for Rook by finding the rook and scanning four directions on a chessboard grid.

6 min
arraysmatrix

Add to Array-Form of Integer: Digit-by-Digit Addition with Carry

easy

How to solve LeetCode 989 Add to Array-Form of Integer. Process digits from right to left, adding k as a running carry to build the result.

4 min
arraysmath

Vowel Spellchecker: Priority-Based Fuzzy Matching

medium

How to solve LeetCode 966 Vowel Spellchecker. Build three hash maps for exact, case-insensitive, and vowel-insensitive matching in O(n + q) time.

7 min
stringshash-map

Vertical Order Traversal of a Binary Tree: Coordinate Sorting

hard

How to solve LeetCode 987 Vertical Order Traversal. Assign (row, col) coordinates with DFS, sort by column then row then value, and group by column to produce the final output.

7 min
treeshash-map

Verifying an Alien Dictionary: Custom Sort Order Validation

easy

How to solve LeetCode 953 Verifying an Alien Dictionary. Map alien character order to indices and verify adjacent word pairs are sorted in O(n * m) time.

7 min
arraysstrings

Validate Stack Sequences: Greedy Stack Simulation

medium

How to solve LeetCode 946 Validate Stack Sequences by simulating push and pop operations with a greedy approach. Push elements and eagerly pop whenever possible.

7 min
arraysstacks

Valid Mountain Array: Linear Scan

easy

How to solve LeetCode 941 Valid Mountain Array. Use a single-pass linear scan to climb up then climb down, verifying the array forms a strict mountain shape.

5 min
arrays

Univalued Binary Tree: Simple Tree Traversal Check

easy

How to solve LeetCode 965 Univalued Binary Tree. Use DFS to verify every node shares the same value in O(n) time.

7 min
trees

Unique Paths III: Walk Every Square Exactly Once

hard

How to solve LeetCode 980 Unique Paths III. Use backtracking to find all paths from start to end that visit every walkable cell exactly once.

6 min
arraysbacktracking

Unique Email Addresses: String Normalization

easy

How to solve LeetCode 929 Unique Email Addresses. Normalize email local names by removing dots and ignoring plus suffixes, then count unique addresses.

4 min
arraysstrings

Triples with Bitwise AND Equal To Zero: Precompute Pairwise Results

hard

How to solve LeetCode 982 Triples with Bitwise AND Equal To Zero. Precompute pairwise AND results to reduce O(n^3) to O(n^2 + n * max_val).

6 min
arraysbit-manipulation

Time Based Key-Value Store: Binary Search Meets Hash Maps

medium

How to solve LeetCode 981 Time Based Key-Value Store. Combine a hash map with binary search on sorted timestamps for efficient versioned lookups.

6 min
designhash-map

Three Equal Parts: Binary Array Partitioning

hard

How to solve LeetCode 927 Three Equal Parts. Count ones and find partition indices where all three parts represent the same binary value.

5 min
arraysmath

Tallest Billboard: DP on Difference Between Two Subsets

hard

How to solve LeetCode 956 Tallest Billboard. Use dynamic programming keyed on the height difference between two supports to find the tallest equal-height partition.

8 min
dynamic-programming

Sum of Even Numbers After Queries: Incremental Even Sum Tracking

medium

How to solve LeetCode 985 Sum of Even Numbers After Queries using incremental updates. Instead of recalculating the even sum from scratch after each query, adjust a running total in O(1) per query.

8 min
arrayssimulation

Subarray Sums Divisible by K: Prefix Sums Meet Modular Arithmetic

medium

How to solve LeetCode 974 Subarray Sums Divisible by K. Use prefix sums with modular arithmetic and a hash map to count subarrays in O(n) time.

6 min
arrayshash-map

String Without AAA or BBB: Greedy Interleaving

medium

How to solve LeetCode 984 String Without AAA or BBB using a greedy approach. Always place two of the more frequent character, then one of the less frequent, to avoid triple runs.

7 min
stringsgreedy

Stamping The Sequence: Reverse Greedy Simulation

hard

How to solve LeetCode 936 Stamping The Sequence. Work backwards from the target, greedily un-stamping matches until the entire string is erased.

7 min
stringsstacks

Squares of a Sorted Array: Two Pointers from Both Ends

easy

How to solve LeetCode 977 Squares of a Sorted Array. Use two pointers from both ends to merge squared values into sorted order in O(n) time.

5 min
arrayssorting

Smallest String Starting From Leaf

medium

How to solve LeetCode 988 Smallest String Starting From Leaf. Use DFS to build leaf-to-root strings in a binary tree and return the lexicographically smallest one.

7 min
treesstrings

Shortest Bridge: DFS Plus BFS on a Grid

medium

How to solve LeetCode 934 Shortest Bridge. Use DFS to find one island, then BFS from its boundary to reach the other island in minimum flips.

7 min
arraysgraph

Reveal Cards In Increasing Order: Reverse Simulation with a Deque

medium

How to solve LeetCode 950 Reveal Cards In Increasing Order by sorting cards and simulating the reveal process in reverse using a deque.

7 min
arrayssorting

Reorder Data in Log Files: Custom Sorting

medium

How to solve LeetCode 937 Reorder Data in Log Files. Partition logs by type and apply a custom comparator to sort letter-logs lexicographically while preserving digit-log order.

5 min
arraysstrings

Regions Cut By Slashes: Grid Upscaling with Connected Components

medium

How to solve LeetCode 959 Regions Cut By Slashes. Upscale the grid to 3x3 cells, mark slashes as walls, and count connected components.

7 min
graphunion-find

Range Sum of BST: Pruned DFS

easy

How to solve LeetCode 938 Range Sum of BST by leveraging the BST property to prune unnecessary branches during DFS.

5 min
trees

Prison Cells After N Days: Cycle Detection in State Space

medium

How to solve LeetCode 957 Prison Cells After N Days. Detect the cycle in cell states and use modular arithmetic to skip ahead efficiently.

5 min
arraysbit-manipulation

Powerful Integers: Enumerating Sums of Powers

medium

How to solve LeetCode 970 Powerful Integers. Generate all sums x^i + y^j up to a bound by iterating over powers of x and y.

4 min
mathhash-map

Pancake Sorting: Sorting by Prefix Reversals

medium

How to solve LeetCode 969 Pancake Sorting. Use a selection sort strategy with prefix reversals to place each element in its correct position.

5 min
arraysgreedy

Odd Even Jump: Monotonic Stack Meets Dynamic Programming

hard

How to solve LeetCode 975 Odd Even Jump. Use a monotonic stack to precompute jump targets and DP to determine which indices reach the end.

7 min
arraysdynamic-programming

Numbers With Same Consecutive Differences: Digit-by-Digit BFS

medium

How to solve LeetCode 967 Numbers With Same Consecutive Differences. Use BFS or DFS to build valid numbers digit by digit in O(2^n) time.

7 min
backtracking

Number of Recent Calls: Queue-Based Sliding Window

easy

How to solve LeetCode 933 Number of Recent Calls. Use a queue to track timestamps and remove expired entries to count recent pings.

6 min
design

N-Repeated Element in Size 2N Array: Finding the Majority with a Set

easy

How to solve LeetCode 961 N-Repeated Element in Size 2N Array. Use a hash set to find the element that appears n times in a 2n-length array.

5 min
arrayshash-map

Most Stones Removed with Same Row or Column: Union-Find Connected Components

medium

How to solve LeetCode 947 Most Stones Removed with Same Row or Column using union-find. Connect stones that share a row or column, then count connected components.

8 min
graphunion-find

Minimum Increment to Make Array Unique: Sort and Bump

medium

How to solve LeetCode 945 Minimum Increment to Make Array Unique using a greedy sort-and-bump approach. Sort the array and push duplicates forward one at a time.

7 min
arraysgreedy

Minimum Falling Path Sum: Matrix Dynamic Programming

medium

How to solve LeetCode 931 Minimum Falling Path Sum using dynamic programming. Build a DP table row by row, considering three possible predecessors for each cell.

5 min
arraysdynamic-programming

Minimum Cost For Tickets: Dynamic Programming on a Calendar

medium

How to solve LeetCode 983 Minimum Cost For Tickets. Use dynamic programming over travel days to find the cheapest combination of 1-day, 7-day, and 30-day passes.

7 min
dynamic-programming

Minimum Area Rectangle: Hash Set Geometry

medium

How to solve LeetCode 939 Minimum Area Rectangle by using a hash set to find axis-aligned rectangles from scattered points. Clean visual approach with Python solution.

4 min
arrayshash-map

Minimum Area Rectangle II: Diagonal-Based Geometry

medium

How to solve LeetCode 963 Minimum Area Rectangle II. Group point pairs by diagonal center and length to find the smallest non-axis-aligned rectangle.

7 min
arraysmath

Minimize Malware Spread II: Graph Component Analysis

hard

How to solve LeetCode 928 Minimize Malware Spread II using Union-Find. Remove infected nodes completely and find which removal saves the most clean nodes.

7 min
graphunion-find

Maximum Width Ramp: Stack-Based Optimal Pairs

medium

How to solve LeetCode 962 Maximum Width Ramp. Use a decreasing stack to find the widest pair where nums[i] <= nums[j] in O(n) time.

8 min
arraysstacks

Longest Turbulent Subarray: Tracking Alternating Comparisons

medium

How to solve LeetCode 978 Longest Turbulent Subarray. Track increasing and decreasing streak lengths that swap on alternation for an O(n) solution.

5 min
arraysdynamic-programming

Largest Time for Given Digits: Permutation and Validation

medium

How to solve LeetCode 949 Largest Time for Given Digits by generating all permutations of four digits and validating each as a 24-hour time.

6 min
strings

Largest Perimeter Triangle: Greedy Sorting for the Triangle Inequality

easy

How to solve LeetCode 976 Largest Perimeter Triangle. Sort descending and greedily check consecutive triples for the triangle inequality.

4 min
arraysmath

Largest Component Size by Common Factor: Union-Find with Prime Factorization

hard

How to solve LeetCode 952 Largest Component Size by Common Factor. Use union-find with prime factorization to group numbers sharing common factors in O(n * sqrt(max)) time.

9 min
arraysmath

Knight Dialer: Dynamic Programming on a Keypad

medium

How to solve LeetCode 935 Knight Dialer. Use dynamic programming to count the number of distinct phone numbers a chess knight can dial.

6 min
dynamic-programming

K Closest Points to Origin: Heap and Quickselect Solutions

medium

How to solve LeetCode 973 K Closest Points to Origin. Use a max-heap or quickselect to efficiently find the k points nearest to the origin.

5 min
arrayssorting

Interval List Intersections: Two-Pointer Merge

medium

How to solve LeetCode 986 Interval List Intersections with a two-pointer technique. Walk through the approach, Python solution, edge cases, and reusable building blocks.

6 min
arraystwo-pointers

Flip Equivalent Binary Trees: Recursive Tree Comparison

medium

How to solve LeetCode 951 Flip Equivalent Binary Trees using recursive comparison. At each node, check if children match directly or after flipping.

7 min
trees

Flip Binary Tree To Match Preorder Traversal: Greedy DFS Approach

medium

How to solve LeetCode 971 Flip Binary Tree To Match Preorder Traversal. Use DFS with greedy child swapping to match a target preorder sequence.

6 min
trees

Find the Shortest Superstring: Bitmask DP on Overlaps

hard

How to solve LeetCode 943 Find the Shortest Superstring using bitmask DP. Precompute pairwise overlaps and use TSP-style dynamic programming to find the optimal word ordering.

7 min
stringsdynamic-programming

Distribute Coins in Binary Tree: Counting the Cost of Balance

medium

How to solve LeetCode 979 Distribute Coins in Binary Tree. Use post-order DFS to calculate excess coins at each node and count the moves needed.

6 min
trees

Distinct Subsequences II: DP with Duplicate Tracking

hard

How to solve LeetCode 940 Distinct Subsequences II. Use dynamic programming with a last-seen character map to count distinct non-empty subsequences while avoiding duplicates.

6 min
stringsdynamic-programming

DI String Match: Greedy Two-Pointer Construction

easy

How to solve LeetCode 942 DI String Match using a greedy two-pointer approach. Use low for 'I' and high for 'D' to build a valid permutation in one pass.

7 min
arraysmath

Delete Columns to Make Sorted: Column-Wise Validation

easy

How to solve LeetCode 944 Delete Columns to Make Sorted by checking each column for sorted order. A clean column iteration pattern.

6 min
arraysstrings

Delete Columns to Make Sorted III: Longest Increasing Subsequence on Columns

hard

How to solve LeetCode 960 Delete Columns to Make Sorted III. Apply LIS dynamic programming on columns where each column is compared row-wise.

6 min
dynamic-programming

Delete Columns to Make Sorted II: Greedy Column Selection

medium

How to solve LeetCode 955 Delete Columns to Make Sorted II. Track which row pairs are already settled by strict ordering and greedily keep columns that don't break unsettled pairs.

7 min
arraysstrings

Check Completeness of a Binary Tree: BFS Level-Order Validation

medium

How to solve LeetCode 958 Check Completeness of a Binary Tree. Use BFS to detect gaps in level-order traversal and validate completeness.

5 min
trees

Binary Tree Cameras: Minimum Cameras with Greedy DFS

hard

How to solve LeetCode 968 Binary Tree Cameras. Use a bottom-up greedy approach with three node states to place the minimum number of cameras covering every node.

7 min
treesdynamic-programming

Binary Subarrays With Sum: Prefix Sum Counting

medium

How to solve LeetCode 930 Binary Subarrays With Sum using prefix sums and a hash map. Count subarrays with a given sum in O(n) time.

5 min
arrayshash-map

Beautiful Array: Divide and Conquer Construction

medium

How to solve LeetCode 932 Beautiful Array. Use divide and conquer to build an array where no element is the arithmetic mean of two others.

6 min
arraysdivide-and-conquer

Bag of Tokens: Greedy Two-Pointer Strategy

medium

How to solve LeetCode 948 Bag of Tokens using a greedy two-pointer approach. Sort tokens, spend power on cheap tokens face-up, and trade score for power on expensive tokens face-down.

8 min
arraysgreedy

Array of Doubled Pairs: Greedy Matching with Frequency Maps

medium

How to solve LeetCode 954 Array of Doubled Pairs. Sort by absolute value and greedily match each element with its double using a frequency counter in O(n log n) time.

7 min
arrayshash-map

X of a Kind in a Deck of Cards: GCD to the Rescue

easy

How to solve LeetCode 914 X of a Kind in a Deck of Cards. Count card frequencies and check if their GCD is at least 2.

5 min
arrayshash-map

Word Subsets: Merging Character Requirements

medium

How to solve LeetCode 916 Word Subsets. Merge all subset requirements into one max-frequency map, then filter words in a single pass.

6 min
arraysstrings

Walking Robot Simulation: Grid Traversal with Obstacle Avoidance

medium

How to solve LeetCode 874 Walking Robot Simulation using direction vectors and a hash set for obstacles. Visual walkthrough with Python solution.

5 min
arrayshash-map

Uncommon Words from Two Sentences: Hash Map Counting

easy

How to solve LeetCode 884 Uncommon Words from Two Sentences. Visual frequency counting approach with Python.

4 min
stringshash-map

Transpose Matrix: Row-Column Swap Pattern

easy

How to solve LeetCode 867 Transpose Matrix by swapping rows and columns. Build intuition for matrix transformations that appear in image processing and linear algebra problems.

7 min
arraysmatrix

Surface Area of 3D Shapes: Grid Geometry

easy

How to solve LeetCode 892 Surface Area of 3D Shapes. Count exposed faces by computing each column's contribution and subtracting neighbor overlaps.

4 min
arraysmath

Super Palindromes: Enumerating Palindromic Squares

hard

How to solve LeetCode 906 Super Palindromes. Generate palindrome roots, square them, and check if the square is also a palindrome.

7 min
math

Super Egg Drop: Flipping the DP Perspective

hard

How to solve LeetCode 887 Super Egg Drop. Visual DP walkthrough showing how to reframe the question from 'minimum moves for n floors' to 'maximum floors with t moves'.

7 min
mathdynamic-programming

Sum of Subsequence Widths: Sorting and Combinatorics

hard

How to solve LeetCode 891 Sum of Subsequence Widths. Sort the array and use powers of two to count each element's contribution as max and min across all subsequences.

5 min
arraysmath

Sum of Subarray Minimums: Monotonic Stack Contribution Technique

medium

How to solve LeetCode 907 Sum of Subarray Minimums using a monotonic stack to compute each element's contribution. Visual walkthrough of the left/right boundary approach.

6 min
arraysstacks

Stone Game: Game Theory and Dynamic Programming

medium

How to solve LeetCode 877 Stone Game using mathematical insight and interval DP. Visual walkthrough with Python solution.

6 min
mathdynamic-programming

Spiral Matrix III: Walking a Spiral from Any Starting Point

medium

How to solve LeetCode 885 Spiral Matrix III. Visual simulation of spiral traversal with direction cycling and boundary checks.

5 min
arraysmatrix

Sort Array By Parity: Two-Pointer Partition

easy

How to solve LeetCode 905 Sort Array By Parity using a two-pointer swap. Partition even numbers to the front in one pass.

7 min
arrayssorting

Sort Array By Parity II: Two-Pointer Placement

easy

How to solve LeetCode 922 Sort Array By Parity II. Use two pointers to place even numbers at even indices and odd numbers at odd indices in O(n) time.

6 min
arrayssorting

Sort an Array: Merge Sort from Scratch

medium

How to solve LeetCode 912 Sort an Array. Build merge sort from scratch to understand divide-and-conquer sorting.

5 min
arrayssorting

Snakes and Ladders: BFS on a Board Game

medium

How to solve LeetCode 909 Snakes and Ladders using BFS to find the minimum number of dice rolls to reach the final square, handling boustrophedon numbering and snake/ladder jumps.

6 min
arraysgraph

Smallest Range II: Minimizing the Gap After Adding or Subtracting k

medium

How to solve LeetCode 910 Smallest Range II. Sort the array, try every split point, and compute the minimum possible range after adding or subtracting k from each element.

6 min
arraysmath

Smallest Range I: Shrink the Gap with Math

easy

How to solve LeetCode 908 Smallest Range I in O(n) time. The key insight: increase the min by k and decrease the max by k.

5 min
arraysmath

RLE Iterator: Consuming a Run-Length Encoded Sequence

medium

How to solve LeetCode 900 RLE Iterator. Use a pointer to walk through the encoded array, consuming counts across multiple next calls.

5 min
arraysdesign

Reverse Only Letters: Two Pointer Approach for Selective Reversal

easy

How to solve LeetCode 917 Reverse Only Letters. Use two pointers to reverse only alphabetic characters in a string while preserving special character positions.

4 min
stringstwo-pointers

Reordered Power of 2: Digit Frequency Matching

medium

How to solve LeetCode 869 Reordered Power of 2 by comparing digit frequencies. Learn why sorting digits creates a canonical form for anagram comparison.

6 min
mathhash-map

Reachable Nodes in Subdivided Graph: Modified Dijkstra

hard

How to solve LeetCode 882 Reachable Nodes In Subdivided Graph using modified Dijkstra's algorithm with a min-heap. Visual walkthrough with Python solution.

6 min
graphheap

Projection Area of 3D Shapes: Count What You Can See

easy

How to solve LeetCode 883 Projection Area of 3D Shapes. Visual breakdown of top, front, and side projections with a clean Python solution.

5 min
arraysmath

Profitable Schemes: 3D Dynamic Programming

hard

How to solve LeetCode 879 Profitable Schemes using 3D DP with space optimization. Visual walkthrough with Python solution.

5 min
dynamic-programming

Possible Bipartition: Graph Two-Coloring with BFS

medium

How to solve LeetCode 886 Possible Bipartition. Visual graph coloring walkthrough using BFS to check if a bipartite split exists.

5 min
graph

Partition Array into Disjoint Intervals: Finding the Split Point

medium

How to solve LeetCode 915 Partition Array into Disjoint Intervals. Use prefix max and suffix min to find where every left element is at most every right element.

6 min
arrays

Orderly Queue: When One Move Changes Everything

hard

How to solve LeetCode 899 Orderly Queue. With k=1 you can only rotate, but k>=2 lets you sort the entire string. A beautiful math insight.

5 min
mathstrings

Online Election: Precompute Leaders and Binary Search

medium

How to solve LeetCode 911 Online Election. Precompute the leading candidate at each vote time, then answer queries in O(log n) with binary search.

7 min
arraysbinary-search

Number of Music Playlists: DP with Replay Constraints

hard

How to solve LeetCode 920 Number of Music Playlists. Use dynamic programming to count valid playlists under the constraint that songs cannot repeat until k other songs have played.

5 min
mathdynamic-programming

Nth Magical Number: Binary Search and Inclusion-Exclusion

hard

How to solve LeetCode 878 Nth Magical Number using binary search with the inclusion-exclusion counting formula. Visual walkthrough with Python solution.

5 min
mathbinary-search

Monotonic Array: Single-Pass Flag Check

easy

How to solve LeetCode 896 Monotonic Array by tracking two boolean flags in a single pass through the array.

3 min
arrays

Minimum Number of Refueling Stops: Greedy with a Max Heap

hard

How to solve LeetCode 871 Minimum Number of Refueling Stops using a greedy max-heap strategy. Learn why deferring decisions until forced leads to the optimal number of stops.

8 min
arraysgreedy

Minimum Add to Make Parentheses Valid: Greedy Balance Counting

medium

How to solve LeetCode 921 Minimum Add to Make Parentheses Valid. Use a greedy counter approach to track unmatched open and close parentheses in O(n) time and O(1) space.

6 min
stringsstacks

Minimize Malware Spread: Union-Find Component Analysis

hard

How to solve LeetCode 924 Minimize Malware Spread. Use Union-Find to identify which infected node removal saves the most nodes from infection.

6 min
graphunion-find

Middle of the Linked List: The Slow and Fast Pointer Technique

easy

How to solve LeetCode 876 Middle of the Linked List using the tortoise and hare approach. Visual walkthrough with Python solution.

4 min
linked-liststwo-pointers

Maximum Sum Circular Subarray: Kadane's Algorithm Extended

medium

How to solve LeetCode 918 Maximum Sum Circular Subarray. Extend Kadane's algorithm to handle circular arrays by finding both max and min subarrays.

5 min
arraysdynamic-programming

Maximum Frequency Stack: Stack of Stacks by Frequency

hard

How to solve LeetCode 895 Maximum Frequency Stack with a frequency map and group map for O(1) push and pop.

5 min
stackshash-map

Long Pressed Name: Two-Pointer Character Matching

easy

How to solve LeetCode 925 Long Pressed Name. Use two pointers to verify if a typed string could result from long-pressing keys of a name.

6 min
stringstwo-pointers

Length of Longest Fibonacci Subsequence: Hash Set + DP

medium

How to solve LeetCode 873 Length of Longest Fibonacci Subsequence using hash map lookups and dynamic programming. Visual walkthrough with Python solution.

5 min
arrayshash-map

Leaf-Similar Trees: Comparing Leaf Sequences

easy

How to solve LeetCode 872 Leaf-Similar Trees by collecting leaf sequences with DFS. Visual walkthrough with Python solution.

5 min
trees

Increasing Order Search Tree: Flatten a BST with Inorder Traversal

easy

How to solve LeetCode 897 Increasing Order Search Tree by using inorder traversal to rearrange a BST into a right-only chain.

3 min
trees

Groups of Special-Equivalent Strings: Canonical Key Grouping

medium

How to solve LeetCode 893 Groups of Special-Equivalent Strings using sorted even/odd index keys and a hash map.

4 min
arraysstrings

Fruit Into Baskets: Sliding Window with Two Fruit Types

medium

How to solve LeetCode 904 Fruit Into Baskets using a sliding window. Track at most two fruit types with a hash map and maximize your collection.

5 min
arrayshash-map

Flip String to Monotone Increasing: Prefix Counting

medium

How to solve LeetCode 926 Flip String to Monotone Increasing. Track ones seen and minimum flips in a single pass to find the cheapest way to make a binary string non-decreasing.

6 min
stringsdynamic-programming

Find and Replace Pattern: Bijection Mapping

medium

How to solve LeetCode 890 Find and Replace Pattern. Use two hash maps to verify a bijection between pattern and word characters.

5 min
arraysstrings

Fair Candy Swap: Hash Set Lookup

easy

How to solve LeetCode 888 Fair Candy Swap. Use a hash set to find the pair that equalizes totals in O(n) time.

4 min
arrayshash-map

Decoded String at Index: Reverse Traversal Without Building the String

medium

How to solve LeetCode 880 Decoded String at Index using reverse traversal. Find the k-th character of a decoded string without constructing it.

5 min
stringsstacks

Construct Binary Tree from Preorder and Postorder: Recursive Partitioning

medium

How to solve LeetCode 889 Construct Binary Tree from Preorder and Postorder Traversal. Use recursive partitioning to rebuild the tree in O(n) time.

4 min
arraystrees

Complete Binary Tree Inserter: BFS Queue Design

medium

How to solve LeetCode 919 Complete Binary Tree Inserter. Design a data structure that inserts into a complete binary tree in O(1) time using a BFS queue.

5 min
treesdesign

Cat and Mouse: Game Theory on Graphs

hard

How to solve LeetCode 913 Cat and Mouse. Use backward induction and game state DP to determine the winner of a pursuit game on a graph.

8 min
graphdynamic-programming

Boats to Save People: Greedy Two Pointers

medium

How to solve LeetCode 881 Boats to Save People using sorting and a greedy two-pointer approach. Visual walkthrough with Python solution.

5 min
arraysgreedy

Bitwise ORs of Subarrays: Tracking Distinct OR Values Efficiently

medium

How to solve LeetCode 898 Bitwise ORs of Subarrays. Track reachable OR values at each position using set propagation to count distinct results.

6 min
arraysbit-manipulation

Binary Gap: Finding the Longest Distance Between 1-Bits

easy

How to solve LeetCode 868 Binary Gap by scanning bit positions. Learn the pattern of tracking previous occurrences while iterating through binary representations.

5 min
bit-manipulation

All Possible Full Binary Trees: Recursive Construction with Memoization

medium

How to solve LeetCode 894 by recursively splitting nodes into left and right subtrees and caching results for each odd n.

5 min
treesdynamic-programming

Advantage Shuffle: Greedy Matching with Sorted Arrays

medium

How to solve LeetCode 870 Advantage Shuffle using a greedy strategy. Learn the pattern of matching sorted elements to maximize wins, similar to the classic horse racing problem.

7 min
arraysgreedy

3Sum With Multiplicity: Counting Combinations

medium

How to solve LeetCode 923 3Sum With Multiplicity. Use value frequency counting and combinatorics to count tuples summing to target in O(n + W^2) time.

6 min
arrayshash-map

Unique Morse Code Words: Hash Set Deduplication

easy

How to solve LeetCode 804 Unique Morse Code Words by converting each word to its Morse code representation and counting unique transformations with a set.

4 min
stringshash-map

Sum of Distances in Tree: Re-rooting Technique

hard

How to solve LeetCode 834 Sum of Distances in Tree using the re-rooting technique. Two DFS passes to compute all node distances in O(n).

6 min
treesgraph

Subdomain Visit Count: Hash Map Aggregation

medium

How to solve LeetCode 811 Subdomain Visit Count by splitting domains into subdomains and aggregating visit counts with a hash map.

5 min
stringshash-map

Split Array into Fibonacci Sequence: Backtracking with Pruning

medium

How to solve LeetCode 842 Split Array into Fibonacci Sequence using backtracking. Leading-zero handling, integer overflow checks, and pruning explained visually.

8 min
stringsbacktracking

Soup Servings: Probability with Memoized Recursion

medium

How to solve LeetCode 808 Soup Servings using memoized recursion to compute the probability that soup A empties first, with Python code and visual walkthrough.

4 min
mathdynamic-programming

Smallest Subtree with all the Deepest Nodes: Bottom-Up Depth Comparison

medium

How to solve LeetCode 865 Smallest Subtree with all the Deepest Nodes using recursive depth comparison. The key insight: if left depth equals right depth, the current node is the answer.

8 min
trees

Similar String Groups: Union-Find Explained

hard

How to solve LeetCode 839 Similar String Groups using Union-Find. Visual walkthrough of grouping anagram strings by swap similarity.

5 min
stringsgraph

Shortest Subarray with Sum at Least K: Prefix Sums Meet a Monotonic Deque

hard

How to solve LeetCode 862 Shortest Subarray with Sum at Least K using prefix sums and a monotonic deque. The key is maintaining a deque of candidate start indices in increasing order of their prefix sums.

8 min
arraysbinary-search

Shortest Path Visiting All Nodes: BFS with Bitmask

hard

How to solve LeetCode 847 Shortest Path Visiting All Nodes using BFS with bitmask state tracking. Visit every node in the minimum number of steps.

8 min
graphbit-manipulation

Shortest Path to Get All Keys: BFS with Bitmask State

hard

How to solve LeetCode 864 Shortest Path to Get All Keys using BFS with bitmask state tracking. Encode collected keys as bits and search (row, col, keys) states.

9 min
graphbit-manipulation

Shortest Distance to a Character: Two-Pass Array Sweep

easy

How to solve LeetCode 821 Shortest Distance to a Character using two passes over the array. Visual walkthrough of bidirectional distance computation.

5 min
arrays

Short Encoding of Words: Suffix Deduplication with Tries

medium

How to solve LeetCode 820 Short Encoding of Words by removing suffix duplicates using a trie or set-based approach. Visual walkthrough of suffix matching.

7 min
stringstrie

Shifting Letters: Suffix Sum for Character Shifts

medium

How to solve LeetCode 848 Shifting Letters with a suffix sum approach. Accumulate shifts from right to left and apply modular arithmetic.

6 min
arraysstrings

Score of Parentheses: Stack-Based Scoring of Nested Brackets

medium

How to solve LeetCode 856 Score of Parentheses. Use a stack to track nesting depth and compute scores for balanced parentheses strings.

6 min
stringsstacks

Score After Flipping Matrix: Greedy Bit Maximization

medium

How to solve LeetCode 861 Score After Flipping Matrix using a greedy approach. The key insight is that the most significant bit of every row is worth more than all other bits combined.

8 min
arraysgreedy

Rectangle Overlap: Axis Projection Check

easy

How to solve LeetCode 836 Rectangle Overlap. Check if two rectangles overlap by testing axis projections independently.

4 min
math

Push Dominoes: Force Simulation Explained

medium

How to solve LeetCode 838 Push Dominoes using force simulation. Visual walkthrough of the two-pass approach.

6 min
stringstwo-pointers

Positions of Large Groups: Linear Scan Grouping

easy

How to solve LeetCode 830 Positions of Large Groups by scanning for runs of identical characters. Visual walkthrough of the linear grouping approach.

4 min
strings

Peak Index in a Mountain Array: Binary Search on Shape

medium

How to solve LeetCode 852 Peak Index in a Mountain Array with binary search. Find the peak of a mountain array in O(log n) time.

6 min
arraysbinary-search

Number of Lines To Write String: Greedy Line Filling

easy

How to solve LeetCode 806 Number of Lines To Write String by greedily placing characters on lines with a 100-pixel width limit, with Python code and visual walkthrough.

4 min
strings

New 21 Game: Sliding Window DP Explained

medium

How to solve LeetCode 837 New 21 Game using dynamic programming with a sliding window. Visual walkthrough of probability calculations.

6 min
dynamic-programmingsliding-window

Most Profit Assigning Work: Greedy Job Assignment

medium

How to solve LeetCode 826 Most Profit Assigning Work using sorting and two pointers. Visual walkthrough of greedy profit maximization for worker-job assignment.

5 min
arraysbinary-search

Most Common Word: Filtering and Counting with Hash Maps

easy

How to solve LeetCode 819 Most Common Word by normalizing text, filtering banned words, and counting frequencies. Visual walkthrough of string parsing with hash maps.

5 min
stringshash-map

Mirror Reflection: Unfolding a Laser Beam with GCD

medium

How to solve LeetCode 858 Mirror Reflection. Unfold the mirror room into stacked copies and use GCD to determine which receptor the laser hits.

7 min
math

Minimum Cost to Hire K Workers: Greedy Ratios with a Max-Heap

hard

How to solve LeetCode 857 Minimum Cost to Hire K Workers. Sort by wage-to-quality ratio and use a max-heap to minimize the total cost of hiring k workers.

8 min
arraysgreedy

Maximize Distance to Closest Person: Gap Scanning

medium

How to solve LeetCode 849 Maximize Distance to Closest Person by scanning gaps between occupied seats. Find the optimal empty seat in one pass.

7 min
arrays

Max Increase to Keep City Skyline: Row and Column Constraints

medium

How to solve LeetCode 807 Max Increase to Keep City Skyline by computing row and column maximums and taking the minimum constraint for each cell, with Python code and visual walkthrough.

5 min
arraysmatrix

Masking Personal Information: String Parsing

medium

How to solve LeetCode 831 Masking Personal Information by detecting emails vs phone numbers and applying masking rules. Visual walkthrough of the parsing approach.

5 min
strings

Making A Large Island: Union-Find Grid Strategy

hard

How to solve LeetCode 827 Making A Large Island using DFS island labeling and flipping a zero to connect components. Visual walkthrough of the grid union strategy.

6 min
arraysgraph

Magic Squares In Grid: Subgrid Validation Explained

medium

How to solve LeetCode 840 Magic Squares In Grid. Visual walkthrough of sliding window validation for 3x3 magic squares.

6 min
arraysmath

Loud and Rich: DFS on a Wealth Graph

medium

How to solve LeetCode 851 Loud and Rich using DFS with memoization on a directed graph. Find the quietest person among all richer-or-equal people.

6 min
arraysgraph

Longest Mountain in Array: Expand From Peaks

medium

How to solve LeetCode 845 Longest Mountain in Array using the expand-from-peak approach and DP with up/down arrays. Visual walkthrough with O(n) solutions.

5 min
arraystwo-pointers

Linked List Components: Counting Connected Subgroups

medium

How to solve LeetCode 817 Linked List Components by traversing the list and counting transitions out of a subset. Visual walkthrough with hash set lookup.

5 min
linked-listshash-map

Lemonade Change: Greedy Change-Making

easy

How to solve LeetCode 860 Lemonade Change using a greedy approach. Track bill counts and always prefer giving a ten-dollar bill as change.

8 min
arraysgreedy

Largest Triangle Area: Brute Force with the Shoelace Formula

easy

How to solve LeetCode 812 Largest Triangle Area by trying all point triples and computing area with the Shoelace formula.

6 min
math

Largest Sum of Averages: Partition DP with Prefix Sums

medium

How to solve LeetCode 813 Largest Sum of Averages using dynamic programming with prefix sums to maximize the sum of group averages.

5 min
dynamic-programming

Keys and Rooms: Graph Traversal Explained

medium

How to solve LeetCode 841 Keys and Rooms using DFS. Visual walkthrough of graph reachability from a starting node.

5 min
graph

Image Overlap: Translation Vector Counting

medium

How to solve LeetCode 835 Image Overlap by counting translation vectors. An elegant approach using coordinate pairs and hash maps.

6 min
arraysmatrix

Hand of Straights: Greedy Grouping with Frequency Counting

medium

How to solve LeetCode 846 Hand of Straights using a greedy approach with sorted iteration and a frequency map. Step-by-step visual walkthrough.

6 min
arrayshash-map

Guess the Word: Minimax Elimination Strategy

hard

How to solve LeetCode 843 Guess the Word using a minimax approach. Visual walkthrough of narrowing a word list through strategic guessing.

6 min
strings

Goat Latin: String Transformation Word by Word

easy

How to solve LeetCode 824 Goat Latin by processing each word based on its first character. Visual walkthrough of vowel and consonant transformation rules.

4 min
strings

Friends Of Appropriate Ages: Counting Valid Friend Requests

medium

How to solve LeetCode 825 Friends Of Appropriate Ages using age frequency counting. Visual walkthrough of the friend request conditions and counting approach.

5 min
arraysbinary-search

Flipping an Image: Row Reverse and Bit Flip

easy

How to solve LeetCode 832 Flipping an Image. Reverse each row and flip bits in a single pass with Python.

5 min
arraysmatrix

Find Eventual Safe States: Graph Cycle Detection

medium

How to solve LeetCode 802 Find Eventual Safe States using DFS coloring to identify nodes not part of any cycle, with Python code and visual walkthrough.

5 min
graph

Find And Replace in String: Right-to-Left Replacement

medium

How to solve LeetCode 833 Find And Replace in String. Process replacements from right to left to avoid index shifting.

4 min
stringssorting

Expressive Words: Two-Pointer Group Matching

medium

How to solve LeetCode 809 Expressive Words by comparing character groups with a two-pointer approach to determine which words can be stretched to match a target string.

6 min
stringstwo-pointers

Count Unique Characters of All Substrings: Contribution Counting

hard

How to solve LeetCode 828 Count Unique Characters of All Substrings using per-character contribution counting. Visual walkthrough of the O(n) approach.

6 min
stringsdynamic-programming

Consecutive Numbers Sum: Mathematical Decomposition

hard

How to solve LeetCode 829 Consecutive Numbers Sum using arithmetic series math. Visual walkthrough of finding all ways to express n as consecutive integers.

5 min
math

Card Flipping Game: Finding the Minimum Good Number

medium

How to solve LeetCode 822 Card Flipping Game by identifying numbers that appear on both sides of the same card. Visual walkthrough with hash set approach.

5 min
arrayshash-map

Car Fleet: Sort and Stack to Count Collisions

medium

How to solve LeetCode 853 Car Fleet. Sort cars by position, compute arrival times, and use a stack-based greedy approach to count distinct fleets.

8 min
arraysstacks

Buddy Strings: One Swap to Make Strings Equal

easy

How to solve LeetCode 859 Buddy Strings. Find differing positions between two strings and check if exactly one swap makes them equal.

5 min
stringshash-map

Binary Trees With Factors: Counting Factor Trees with DP

medium

How to solve LeetCode 823 Binary Trees With Factors using dynamic programming on sorted values. Visual walkthrough of counting trees where parent equals child product.

5 min
arrayshash-map

Binary Tree Pruning: Post-Order Subtree Removal

medium

How to solve LeetCode 814 Binary Tree Pruning using post-order traversal to remove subtrees that contain no 1s.

6 min
trees

Backspace String Compare: Stack and Two-Pointer Solutions

easy

How to solve LeetCode 844 Backspace String Compare using a stack or an O(1) space two-pointer approach. Visual walkthrough, Python code, and key building blocks.

6 min
stringsstacks

Ambiguous Coordinates: Generating Valid Number Pairs

medium

How to solve LeetCode 816 Ambiguous Coordinates by splitting a digit string and inserting decimal points. Visual walkthrough of enumeration with validity checks.

6 min
strings

All Nodes Distance K in Binary Tree: Parent Pointers and BFS

medium

How to solve LeetCode 863 All Nodes Distance K in Binary Tree using parent pointers and BFS. Convert the tree into an undirected graph, then do a level-by-level search.

8 min
treesgraph

Valid Tic-Tac-Toe State: Invariant Checking

medium

How to solve LeetCode 794 Valid Tic-Tac-Toe State by checking game invariants. Validate turn counts and win conditions to determine if a board state is reachable.

6 min
arraysmatrix

Toeplitz Matrix: Diagonal Consistency Check

easy

How to solve LeetCode 766 Toeplitz Matrix. Check whether every diagonal from top-left to bottom-right has the same element by comparing each cell against its top-left neighbor.

4 min
arraysmatrix

Swim in Rising Water: Binary Search Meets Graph Traversal

hard

How to solve LeetCode 778 Swim in Rising Water with binary search + BFS or min-heap. Visual grid walkthrough.

7 min
graphbinary-search

Subarray Product Less Than K: Sliding Window on Products

medium

How to solve LeetCode 713 Subarray Product Less Than K using a sliding window to count valid subarrays in O(n) time.

6 min
arrayssliding-window

Split Linked List in Parts: Even Distribution with Remainders

medium

How to solve LeetCode 725 Split Linked List in Parts by computing base size and distributing remainder nodes. O(n) solution explained with visual walkthrough.

3 min
linked-lists

Sliding Puzzle: BFS on Board States

hard

How to solve LeetCode 773 Sliding Puzzle using BFS. Visual walkthrough of state-space search on a 2x3 board.

5 min
arraysgraph

Shortest Completing Word: Frequency Counting with Hash Maps

easy

How to solve LeetCode 748 by counting letter frequencies and checking each candidate word. Visual walkthrough of the matching process.

6 min
stringshash-map

Set Intersection Size At Least Two: Greedy Interval Covering

hard

How to solve LeetCode 757 Set Intersection Size At Least Two using a greedy approach that sorts intervals by endpoint and greedily picks points from the right.

5 min
arraysgreedy

Self Dividing Numbers: Check Every Digit

easy

How to solve LeetCode 728 Self Dividing Numbers. Simple digit-by-digit divisibility check with clean Python code.

4 min
math

Rotate String: The Concatenation Trick

easy

How to solve LeetCode 796 by checking if goal is a substring of s+s. Visual walkthrough of the rotation insight.

5 min
strings

Reorganize String: Greedy Character Spacing

medium

How to solve LeetCode 767 Reorganize String. Use a max heap to greedily place the most frequent character first, ensuring no two adjacent characters are the same.

4 min
stringshash-map

Remove Comments: Parsing with a State Machine

medium

How to solve LeetCode 722 Remove Comments using a two-state parser that tracks whether you are inside a block comment. Clean Python solution with visual walkthrough.

6 min
strings

Reach a Number: Greedy Steps with Parity Flip

medium

How to solve LeetCode 754 Reach a Number by greedily stepping right and using a parity argument to determine when to flip a single step's direction.

5 min
math

Pyramid Transition Matrix: Backtracking with Allowed Triples

medium

How to solve LeetCode 756 Pyramid Transition Matrix using backtracking to build each row from allowed triple rules. Visual walkthrough of the recursive approach.

7 min
backtrackingbit-manipulation

Prime Number of Set Bits in Binary Representation: Counting Bits with a Twist

easy

How to solve LeetCode 762 by counting set bits for each number in a range and checking whether the count is prime.

4 min
bit-manipulationmath

Preimage Size of Factorial Zeroes Function: Binary Search on Math

hard

How to solve LeetCode 793 Preimage Size of Factorial Zeroes Function using binary search and Legendre's formula. Find how many integers n have exactly k trailing zeroes in n!.

6 min
mathbinary-search

Prefix and Suffix Search: Trie with Combined Keys

hard

How to solve LeetCode 745 using a trie that combines suffix and prefix into a single lookup key. Visual walkthrough of the combined key insertion strategy.

8 min
triedesign

Prefix and Suffix Search: Combined Key Trie

hard

How to solve LeetCode 745 by merging suffix and prefix into a single trie key. Visual walkthrough of the combined key strategy for dual-constraint lookups.

6 min
triedesign

Partition Labels: Greedy String Partitioning

medium

How to solve LeetCode 763 Partition Labels by greedily splitting a string so each letter appears in at most one part.

5 min
stringsgreedy

Open the Lock: BFS Shortest Path on State Graph

medium

How to solve LeetCode 752 Open the Lock using BFS to find the shortest sequence of moves from 0000 to a target combination while avoiding deadends.

5 min
stringsgraph

Number of Subarrays with Bounded Maximum

medium

How to solve LeetCode 795 by counting valid subarrays with a two-pointer sweep. Visual walkthrough of the boundary tracking approach.

5 min
arraystwo-pointers

Number of Matching Subsequences: Bucket Processing

medium

How to solve LeetCode 792 Number of Matching Subsequences using character buckets. Group words by their next needed character and process them as you scan the string.

5 min
stringshash-map

Number of Atoms: Stack-Based Formula Parsing

hard

How to solve LeetCode 726 Number of Atoms using a stack of hash maps to parse nested chemical formulas. O(n) solution explained with visual walkthrough.

4 min
stringsstacks

Network Delay Time: Dijkstra's Algorithm

medium

How to solve LeetCode 743 Network Delay Time with Dijkstra's shortest path algorithm using a min-heap, with Python code and visual walkthrough.

5 min
graphheap

My Calendar III: Maximum K-Booking with Sweep Line

hard

How to solve LeetCode 732 My Calendar III. Use the sweep line technique with a sorted difference map to find the maximum overlap count.

5 min
designbinary-search

My Calendar II: Preventing Triple Bookings

medium

How to solve LeetCode 731 My Calendar II. Track double bookings separately to prevent triple overlaps with a clean Python solution.

5 min
designbinary-search

My Calendar I: Interval Overlap Detection

medium

How to solve LeetCode 729 My Calendar I. Learn interval overlap detection with a sorted list approach and clean Python solution.

6 min
designbinary-search

Monotone Increasing Digits: Greedy Digit Manipulation

medium

How to solve LeetCode 738 Monotone Increasing Digits with a greedy approach that scans digits right to left, with Python code and visual walkthrough.

4 min
mathgreedy

Minimum Swaps To Make Sequences Increasing

hard

How to solve LeetCode 801 with a two-state DP tracking swap and no-swap decisions at each index. Visual walkthrough of the state transitions.

6 min
dynamic-programming

Minimum Distance Between BST Nodes: Inorder Traversal

easy

How to solve LeetCode 783 Minimum Distance Between BST Nodes with inorder traversal. Visual BST walkthrough.

5 min
trees

Min Cost Climbing Stairs: Bottom-Up DP

easy

How to solve LeetCode 746 with dynamic programming. Visual walkthrough of the cost array and optimal substructure.

6 min
dynamic-programming

Maximum Length of Repeated Subarray: DP Table Matching

medium

How to solve LeetCode 718 Maximum Length of Repeated Subarray using dynamic programming to find the longest common subarray in O(m*n) time.

5 min
arraysdynamic-programming

Max Chunks To Make Sorted: Running Maximum

medium

How to solve LeetCode 769 Max Chunks To Make Sorted. Track the running maximum while scanning left to right. When the maximum equals the current index, you have found a valid chunk boundary.

4 min
arrayssorting

Max Chunks To Make Sorted II: Prefix Max and Suffix Min

hard

How to solve LeetCode 768 Max Chunks To Make Sorted II. Use prefix maximums and suffix minimums to find valid chunk boundaries where sorting each chunk independently produces the fully sorted array.

5 min
arrayssorting

Longest Word in Dictionary: Building Words Character by Character

medium

How to solve LeetCode 720 Longest Word in Dictionary using sorting and a hash set to find the longest buildable word in O(n * k) time.

6 min
stringstrie

Letter Case Permutation: Branching on Every Letter

medium

How to solve LeetCode 784 Letter Case Permutation using backtracking and bit manipulation. Decision tree, step-by-step walkthrough, and complexity analysis.

5 min
stringsbacktracking

Largest Plus Sign: Dynamic Programming on a Grid

medium

How to solve LeetCode 764 by precomputing arm lengths in four directions and taking their minimum to find the largest axis-aligned plus sign of 1s.

7 min
dynamic-programming

Largest Number At Least Twice of Others: Single Pass Array Scan

easy

How to solve LeetCode 747 by tracking the two largest elements in one pass. Visual walkthrough of the dominance check.

4 min
arrays

K-th Symbol in Grammar: Recursive Binary Pattern

medium

How to solve LeetCode 779 K-th Symbol in Grammar using recursion. Visual tree showing how each row generates the next.

5 min
math

Jewels and Stones: Set Membership Counting

easy

How to solve LeetCode 771 Jewels and Stones. Convert jewels to a set for O(1) lookups, then count how many stones appear in the set.

4 min
stringshash-map

Is Graph Bipartite: Two-Color BFS on an Adjacency List

medium

How to solve LeetCode 785 Is Graph Bipartite using BFS two-coloring. Assign colors level by level and detect odd-cycle conflicts in O(V + E).

5 min
graph

Global and Local Inversions: The Key Insight

medium

How to solve LeetCode 775 Global and Local Inversions. Visual explanation of why local inversions are always global, and the one-pass check.

5 min
arraysmath

Flood Fill: DFS on a Grid

easy

How to solve LeetCode 733 Flood Fill. A clean DFS approach to filling connected regions in a matrix with Python code.

5 min
arraysmatrix

Find Smallest Letter Greater Than Target: Binary Search on Letters

easy

How to solve LeetCode 744 with binary search on a sorted character array. Visual walkthrough of pointer movement and wrap-around logic.

6 min
arraysbinary-search

Find Pivot Index: Prefix Sum Balance Point

easy

How to solve LeetCode 724 Find Pivot Index using prefix sums to find where left sum equals right sum. O(n) time solution explained with visual walkthrough.

3 min
arrays

Escape The Ghosts: Manhattan Distance Insight

medium

How to solve LeetCode 789 Escape The Ghosts by comparing Manhattan distances. If any ghost is closer to the target than you are, it can always intercept you.

4 min
math

Domino and Tromino Tiling: Dynamic Programming on a Grid

medium

How to solve LeetCode 790 Domino and Tromino Tiling using dynamic programming. Track full and partial row states to count all valid 2xN tilings.

6 min
dynamic-programming

Delete and Earn: House Robber in Disguise

medium

How to solve LeetCode 740 Delete and Earn by reducing it to the House Robber problem, with Python code and visual walkthrough.

5 min
dynamic-programming

Custom Sort String: Hash Map Counting Approach

medium

How to solve LeetCode 791 Custom Sort String using character counting and custom ordering. Count characters in s, then reconstruct in the order specified.

5 min
stringshash-map

Cracking the Safe: Eulerian Path on De Bruijn Graph

hard

How to solve LeetCode 753 Cracking the Safe by finding an Eulerian path through a De Bruijn graph. Visual walkthrough of the DFS-based approach.

5 min
graph

Couples Holding Hands: Greedy Swaps and Union-Find

hard

How to solve LeetCode 765 Couples Holding Hands by greedily swapping people into the correct seats, with an alternative union-find cycle counting approach.

6 min
graphgreedy

Cherry Pickup: Two-Path DP on a Grid

hard

How to solve LeetCode 741 Cherry Pickup using dynamic programming with two simultaneous walkers, with Python code and visual walkthrough.

6 min
dynamic-programmingmatrix

Cheapest Flights Within K Stops: Bounded Bellman-Ford

medium

How to solve LeetCode 787 Cheapest Flights Within K Stops using a modified Bellman-Ford algorithm with bounded iterations, with Python code and visual walkthrough.

6 min
graphdynamic-programming

Champagne Tower: Simulation with Dynamic Programming

medium

How to solve LeetCode 799 by simulating champagne overflow row by row. Visual walkthrough of the glass pyramid DP approach.

6 min
dynamic-programming

Best Time to Buy and Sell Stock with Transaction Fee: DP State Machine

medium

How to solve LeetCode 714 Best Time to Buy and Sell Stock with Transaction Fee using a two-state DP approach in O(n) time.

6 min
arraysgreedy

Asteroid Collision: Stack Simulation

medium

How to solve LeetCode 735 Asteroid Collision using a stack to simulate asteroid movement and collisions, with Python code and visual walkthrough.

5 min
arraysstacks

All Paths From Source to Target

medium

How to solve LeetCode 797 using DFS backtracking on a DAG. Visual walkthrough of finding every path from node 0 to node n-1.

6 min
graphbacktracking

Accounts Merge: Union-Find on Shared Emails

medium

How to solve LeetCode 721 Accounts Merge using union-find to group accounts by shared emails. O(n alpha(n)) solution explained with visual walkthrough.

6 min
stringsgraph

1-bit and 2-bit Characters: Greedy Bit Scanning

easy

How to solve LeetCode 717 1-bit and 2-bit Characters by greedily scanning bits to determine if the last character is a single-bit character.

5 min
arrays

Valid Parenthesis String: Greedy Range Tracking

medium

How to solve LeetCode 678. Track the range of possible open parenthesis counts to handle wildcards in one pass.

5 min
stringsgreedy

Valid Palindrome II: One Deletion Palindrome Check

easy

How to solve LeetCode 680 Valid Palindrome II using two pointers with one allowed deletion.

5 min
stringstwo-pointers

Two Sum IV - Input is a BST: Hash Set Tree Traversal

easy

How to solve LeetCode 653 Two Sum IV Input is a BST. Traverse the BST while maintaining a hash set to find two nodes whose values sum to the target.

6 min
treeshash-map

Trim a Binary Search Tree: Recursive Range Pruning

medium

How to solve LeetCode 669 with recursion. Use BST properties to decide at each node whether to keep it, skip to the right subtree, or skip to the left subtree based on the given range.

4 min
trees

Top K Frequent Words: Heap with Lexicographic Tie-Breaking

medium

How to solve LeetCode 692 Top K Frequent Words using a heap with custom comparator for lexicographic ordering.

5 min
stringshash-map

To Lower Case: ASCII Arithmetic and Bit Manipulation

easy

How to solve LeetCode 709 To Lower Case. Convert uppercase to lowercase using ASCII offset or bit manipulation in O(n) time and O(n) space.

3 min
strings

Stickers to Spell Word: BFS on Letter States

hard

How to solve LeetCode 691 Stickers to Spell Word using BFS with frequency counting and pruning. Visual diagrams and step-by-step walkthrough.

4 min
dynamic-programmingbacktracking

Split Array into Consecutive Subsequences: Greedy Allocation

medium

How to solve LeetCode 659 Split Array into Consecutive Subsequences using a greedy approach with frequency counting and subsequence tracking.

5 min
arrayshash-map

Solve the Equation: Parsing and Simplifying Linear Equations

medium

How to solve LeetCode 640 Solve the Equation by parsing both sides and collecting coefficients.

5 min
mathstrings

Shopping Offers: Backtracking with Memoization

medium

How to solve LeetCode 638 Shopping Offers using backtracking with memoization to find the minimum cost.

6 min
dynamic-programmingbacktracking

Set Mismatch: Finding the Duplicate and Missing Number

easy

How to solve LeetCode 645 Set Mismatch by finding the duplicated and missing numbers using a hash set or in-place marking.

5 min
arrayshash-map

Second Minimum Node in a Binary Tree: DFS with Pruning

easy

How to solve LeetCode Second Minimum Node in a Binary Tree. Use DFS to find the smallest value that is strictly larger than the root.

6 min
trees

Search in a Binary Search Tree: Using the BST Property

easy

How to solve LeetCode 700 Search in a Binary Search Tree with recursive and iterative approaches. Visual walkthrough of BST navigation.

5 min
treesbinary-search-tree

Robot Return to Origin: Coordinate Tracking

easy

How to solve LeetCode 657 Robot Return to Origin by tracking x and y coordinate changes through a sequence of moves.

4 min
stringssimulation

Replace Words: Prefix Matching with a Trie

medium

How to solve LeetCode 648 Replace Words by building a trie from root words and replacing sentence words with their shortest matching prefix.

7 min
stringstrie

Repeated String Match: Minimum Repetitions for Substring

medium

How to solve LeetCode 686 Repeated String Match by finding the minimum number of times to repeat a string so another is a substring.

5 min
strings

Redundant Connection: Union-Find Cycle Detection

medium

How to solve LeetCode 684 Redundant Connection using union-find to detect the edge that creates a cycle.

7 min
graphunion-find

Redundant Connection II: Directed Graph Cycle Detection

hard

How to solve LeetCode 685 Redundant Connection II by handling two-parent nodes and cycles in directed graphs.

7 min
graph

Print Binary Tree: Level-by-Level Grid Placement

medium

How to solve LeetCode 655 Print Binary Tree by recursively placing nodes into a 2D grid based on tree height and column offsets.

6 min
treesrecursion

Partition to K Equal Sum Subsets: Backtracking with Pruning

medium

How to solve LeetCode 698 Partition to K Equal Sum Subsets using backtracking and bitmask DP. Visual walkthrough of bucket-filling and pruning strategies.

7 min
arraysbacktracking

Number of Longest Increasing Subsequence: DP with Length and Count

medium

How to solve LeetCode Number of Longest Increasing Subsequence. Track both the length and count of LIS ending at each position using DP.

6 min
arraysdynamic-programming

Non-negative Integers without Consecutive Ones: Fibonacci DP on Bits

hard

How to solve LeetCode 600 Non-negative Integers without Consecutive Ones. Process the binary representation bit by bit using a Fibonacci-based DP approach to count valid numbers.

6 min
dynamic-programming

Non-decreasing Array: One Modification Check

medium

How to solve LeetCode 665 by scanning for violations. When you find nums[i] greater than nums[i+1], decide whether to lower nums[i] or raise nums[i+1] and verify the array becomes non-decreasing.

5 min
arrays

Minimum Index Sum of Two Lists: Hash Map Index Tracking

easy

How to solve LeetCode 599 Minimum Index Sum of Two Lists. Use a hash map to store indices from one list, then scan the other to find common entries with the smallest index sum.

5 min
arrayshash-map

Minimum ASCII Delete Sum for Two Strings: DP on String Pairs

medium

How to solve LeetCode 712 Minimum ASCII Delete Sum for Two Strings. Use dynamic programming to find the minimum cost of deletions to make two strings equal.

5 min
stringsdynamic-programming

Maximum Width of Binary Tree: Index-Based BFS

medium

How to solve LeetCode 662 with BFS. Track node positions using binary heap indexing and compute the width as the difference between the rightmost and leftmost positions at each level.

5 min
trees

Maximum Swap: Greedy Digit Swap

medium

How to solve LeetCode Maximum Swap. A greedy approach that tracks the last occurrence of each digit to find the optimal swap.

6 min
mathgreedy

Maximum Sum of 3 Non-Overlapping Subarrays: Left-Middle-Right Scan

hard

How to solve LeetCode 689 Maximum Sum of 3 Non-Overlapping Subarrays using prefix sums and a three-pass scan. O(n) solution with visual diagrams.

6 min
arraysdynamic-programming

Maximum Length of Pair Chain: Greedy Interval Selection

medium

How to solve LeetCode 646 Maximum Length of Pair Chain using a greedy approach that sorts by end value and selects non-overlapping pairs.

5 min
arraysgreedy

Maximum Binary Tree: Recursive Array Partitioning

medium

How to solve LeetCode 654 Maximum Binary Tree. Recursively find the maximum element, make it the root, and build left and right subtrees from the partitioned array.

5 min
arraystrees

Maximum Average Subarray I: Fixed-Size Sliding Window

easy

How to solve LeetCode 643 Maximum Average Subarray I using a fixed-size sliding window for O(n) performance.

4 min
arrayssliding-window

Max Area of Island: DFS Grid Exploration

medium

How to solve LeetCode 695 Max Area of Island using DFS to explore connected components in a grid.

5 min
arraysgraph

Map Sum Pairs: Prefix Sums in a Trie

medium

How to solve LeetCode 677. Use a trie with running sums at each node to efficiently compute prefix-based value totals.

6 min
triehash-map

Longest Univalue Path: DFS Post-Order Counting

medium

How to solve LeetCode 687 Longest Univalue Path using DFS post-order traversal. O(n) solution with visual diagrams and step-by-step walkthrough.

5 min
trees

Longest Continuous Increasing Subsequence: Sliding Window Counter

easy

How to solve LeetCode Longest Continuous Increasing Subsequence. A single pass tracking the current run length with O(n) time and O(1) space.

5 min
arrays

Kth Smallest Number in Multiplication Table: Binary Search on Value

hard

How to solve LeetCode 668 with binary search on the answer. Instead of sorting the entire table, binary search for the smallest value x such that at least k entries in the m by n multiplication table are less than or equal to x.

5 min
binary-searchmath

Kth Largest Element in a Stream: Min-Heap Design

easy

How to solve LeetCode 703 Kth Largest Element in a Stream using a min-heap of size k. Visual walkthrough of the heap-based streaming design.

6 min
treesdesign

Knight Probability in Chessboard: Layer-by-Layer DP

medium

How to solve LeetCode 688 Knight Probability in Chessboard using dynamic programming. O(n^2 * k) solution with visual diagrams and step-by-step walkthrough.

5 min
dynamic-programming

Insert into a Binary Search Tree: Finding the Right Leaf

medium

How to solve LeetCode 701 Insert into a Binary Search Tree with recursive and iterative approaches. Visual walkthrough of BST insertion.

7 min
treesbinary-search-tree

Implement Magic Dictionary: One-Character Fuzzy Matching

medium

How to solve LeetCode 676. Group words by length and check for exactly one character difference to implement fuzzy search.

5 min
stringstrie

Image Smoother: Neighbor Averaging

easy

How to solve LeetCode 661 Image Smoother by averaging each cell with its valid neighbors in a 3x3 window.

5 min
arraysmatrix

Find K Closest Elements: Binary Search Window

medium

How to solve LeetCode 658 Find K Closest Elements using binary search to locate the optimal sliding window of k elements closest to a target.

6 min
arraysbinary-search

Find Duplicate Subtrees: Serialization with Hash Map

medium

How to solve LeetCode 652 Find Duplicate Subtrees. Serialize each subtree during post-order traversal and use a hash map to detect duplicates.

6 min
treeshash-map

Falling Squares: Coordinate Compression and Interval Tracking

hard

How to solve LeetCode 699 Falling Squares using coordinate compression and interval height tracking. Visual walkthrough of square stacking.

6 min
arrayscoordinate-compression

Employee Importance: BFS Graph Traversal

medium

How to solve LeetCode 690 Employee Importance using BFS with a hash map for O(1) lookups. O(n) solution with visual diagrams and step-by-step walkthrough.

4 min
graphhash-map

Dota2 Senate: Greedy Voting with Two Queues

medium

How to solve LeetCode 649 Dota2 Senate using a greedy two-queue simulation where each senator bans the nearest opposing member.

5 min
stringsgreedy

Design Linked List: Build a Linked List From Scratch

medium

How to solve LeetCode 707 Design Linked List. Implement get, addAtHead, addAtTail, addAtIndex, and deleteAtIndex using a singly linked list with a dummy head.

5 min
linked-listsdesign

Design HashSet: Build a Hash Set From Scratch

easy

How to solve LeetCode 705 Design HashSet. Implement add, remove, and contains using an array of buckets with chaining in O(1) average time.

4 min
designhash-map

Design HashMap: Implement a Hash Map From Scratch

easy

How to solve LeetCode 706 Design HashMap. Build put, get, and remove operations using bucket arrays with chaining for O(1) average time.

5 min
designhash-map

Design Circular Deque: Array-Based Ring Buffer

medium

How to solve LeetCode 641 Design Circular Deque using a circular array with front and rear pointers.

6 min
designarrays

Degree of an Array: Hash Map Tracking

easy

How to solve LeetCode 697 Degree of an Array by tracking frequency, first occurrence, and last occurrence in a single pass.

4 min
arrayshash-map

Cut Off Trees for Golf Event: BFS on a Matrix Grid

hard

How to solve LeetCode 675. Sort trees by height, then use BFS to find shortest paths between each consecutive pair.

5 min
arraysmatrix

Count Binary Substrings: The Group Counting Trick

easy

How to solve LeetCode 696 Count Binary Substrings in O(n) time by counting consecutive groups.

4 min
strings

Bulb Switcher II: Pattern Analysis with Four Operations

medium

How to solve LeetCode Bulb Switcher II. Why the answer only depends on the first three bulbs and how to count distinct states.

6 min
math

Binary Number with Alternating Bits: The XOR Trick

easy

How to solve LeetCode 693 Binary Number with Alternating Bits using XOR and bit manipulation in O(1) space.

5 min
bit-manipulation

Beautiful Arrangement II: Constructing k Distinct Differences

medium

How to solve LeetCode 667 by interleaving low and high values. Place alternating smallest and largest unused numbers to create k distinct differences, then fill the rest in ascending order.

4 min
arrays

Baseball Game: Stack-Based Score Tracking

easy

How to solve LeetCode 682 Baseball Game using a stack to track and manipulate scores.

6 min
arraysstacks

Average of Levels in Binary Tree: BFS Level-by-Level

easy

How to solve LeetCode 637 Average of Levels in Binary Tree using BFS to compute level averages.

5 min
treesbfs

24 Game: Backtracking with Arithmetic Expressions

hard

How to solve LeetCode 679. Recursively pick two numbers, apply an operation, reduce the list, and check if 24 is reachable.

5 min
mathbacktracking

2 Keys Keyboard: Prime Factorization Meets Dynamic Programming

medium

How to solve LeetCode 650 2 Keys Keyboard by recognizing that the minimum operations equal the sum of the prime factors of n.

5 min
mathdynamic-programming

Valid Triangle Number: Sort, Fix, Two Pointers

medium

How to solve LeetCode 611 Valid Triangle Number using sorting and two pointers. Fix the largest side and count valid pairs in O(n^2) time.

5 min
arraysbinary-search

Sum of Square Numbers: Two-Pointer Search for Perfect Squares

medium

How to solve LeetCode 633 Sum of Square Numbers using a two-pointer approach to find if a number can be expressed as the sum of two squares.

4 min
mathbinary-search

Subarray Sum Equals K: Prefix Sums Meet Hash Maps

medium

How to solve LeetCode 560 Subarray Sum Equals K using prefix sums and a hash map to count subarrays in O(n) time.

6 min
arrayshash-map

Student Attendance Record I: Single-Pass String Check

easy

How to solve LeetCode 551 Student Attendance Record I by counting absences and tracking consecutive lates in one pass through the string.

5 min
strings

Smallest Range Covering Elements from K Lists: Min-Heap Approach

hard

How to solve LeetCode 632 Smallest Range Covering Elements from K Lists using a min-heap to track pointers across sorted lists.

5 min
arraysheap

Single Element in a Sorted Array: Binary Search on Pairs

medium

How to solve LeetCode 540 Single Element in a Sorted Array using binary search with the even-odd index trick in O(log n) time.

7 min
arraysbinary-search

Shortest Unsorted Continuous Subarray: Finding the Minimum Slice to Sort

medium

How to solve LeetCode 581 Shortest Unsorted Continuous Subarray in O(n) time by tracking max from the left and min from the right.

5 min
arrayssorting

Reverse Words in a String III: Per-Word Reversal in One Line

easy

How to solve LeetCode 557 Reverse Words in a String III by splitting, reversing each word, and joining back together.

4 min
strings

Reverse String II: Chunked Reversal Pattern

easy

How to solve LeetCode 541 Reverse String II by processing the string in 2k-sized chunks and reversing the first k characters of each.

5 min
strings

Reshape the Matrix: Row-Major Index Mapping

easy

How to solve LeetCode 566 Reshape the Matrix using row-major order index conversion between matrix shapes.

6 min
arraysmatrix

Range Addition II: Finding the Overlap of All Operations

easy

How to solve LeetCode 598 Range Addition II by finding the intersection of all operation rectangles. The maximum value cells form the smallest overlapping region.

5 min
arraysmath

Random Pick with Weight: Prefix Sums + Binary Search

medium

How to solve LeetCode 528 Random Pick with Weight using prefix sums and binary search. Pick a weighted random index efficiently with a clear visual walkthrough.

5 min
mathbinary-search

Permutation in String: Fixed-Size Sliding Window with Frequency Matching

medium

How to solve LeetCode 567 Permutation in String using a sliding window and character frequency comparison.

5 min
stringssliding-window

Out of Boundary Paths: 3D Dynamic Programming on a Grid

medium

How to solve LeetCode 576 Out of Boundary Paths using 3D DP. Count the number of ways a ball can exit a grid within a given number of moves.

6 min
dynamic-programming

Optimal Division: Why Greedy Parentheses Always Win

medium

How to solve LeetCode 553 Optimal Division using the mathematical insight that placing parentheses around all denominators maximizes the result.

4 min
math

Number of Provinces: Union-Find for Connected Components

medium

How to solve LeetCode 547 Number of Provinces using Union-Find with path compression and union by rank to count connected components.

5 min
graphunion-find

Non-negative Integers without Consecutive Ones: A Fibonacci DP Approach

hard

How to solve LeetCode 600 by counting integers without consecutive ones in binary using a Fibonacci-based digit DP technique.

5 min
dynamic-programming

Next Greater Element III: Next Permutation on Digits

medium

How to solve LeetCode 556 Next Greater Element III by applying the next permutation algorithm to the digits of an integer.

5 min
mathstrings

N-ary Tree Preorder Traversal: DFS Without Recursion

easy

How to solve LeetCode 589 N-ary Tree Preorder Traversal using iterative DFS with a stack. Visual walkthrough of processing root before children.

5 min
trees

N-ary Tree Postorder Traversal: Process Children Before Parents

easy

How to solve LeetCode 590 N-ary Tree Postorder Traversal using an iterative two-stack approach. Visual walkthrough of visiting children before the root.

5 min
trees

Minimum Time Difference: Circular Sort Trick

medium

How to solve LeetCode 539 Minimum Time Difference by converting to minutes, sorting, and checking the circular wrap-around.

5 min
arraysmath

Minimum Index Sum of Two Lists: Finding Common Favorites Efficiently

easy

How to solve LeetCode 599 Minimum Index Sum of Two Lists using a hash map to find shared elements with the smallest combined index.

4 min
arrayshash-map

Minimum Absolute Difference in BST: Inorder Traversal for Sorted Order

easy

How to solve LeetCode 530 Minimum Absolute Difference in BST. Use inorder traversal to visit nodes in sorted order, then track the minimum gap between consecutive values.

4 min
trees

Minesweeper: Matrix DFS with Recursive Reveal

medium

How to solve LeetCode 529 Minesweeper using DFS. Count adjacent mines, reveal blanks recursively, and stop at numbered borders.

5 min
arraysmatrix

Merge Two Binary Trees: Recursive DFS in One Pass

easy

How to solve LeetCode 617 Merge Two Binary Trees using recursive DFS. A clean pattern for combining two tree structures node by node.

5 min
trees

Maximum Product of Three Numbers: Why Negatives Matter

easy

How to solve LeetCode 628 Maximum Product of Three Numbers. Sorting and linear scan approaches with complexity analysis.

6 min
arraysmath

Longest Word in Dictionary through Deleting: Two-Pointer Subsequence Check

medium

How to solve LeetCode 524 Longest Word in Dictionary through Deleting. Sort the dictionary by length and lexicographic order, then use a two-pointer subsequence check to find the longest matching word.

5 min
stringssorting

Longest Uncommon Subsequence II: Filtering Candidates with Subsequence Checks

medium

How to solve LeetCode 522 Longest Uncommon Subsequence II by checking each string against all others. Sort by length, filter with is_subsequence, and return the first qualifier.

6 min
stringssorting

Longest Uncommon Subsequence I: The Trick Question

easy

How to solve LeetCode 521 Longest Uncommon Subsequence I. If the strings are equal, return -1. If they differ, return the length of the longer string. A two-line solution hiding a real insight.

5 min
strings

Longest Palindromic Subsequence: 2D Dynamic Programming

medium

How to solve LeetCode 516 Longest Palindromic Subsequence using 2D DP. Visual walkthrough of the interval DP table.

6 min
stringsdynamic-programming

Longest Harmonious Subsequence: Counting Adjacent Value Pairs

easy

How to solve LeetCode 594 Longest Harmonious Subsequence using a hash map to count frequencies and find the best pair of values differing by exactly 1.

5 min
arrayshash-map

K Inverse Pairs Array: Counting Permutations with DP

hard

How to solve LeetCode 629 K Inverse Pairs Array using dynamic programming with prefix sums to count permutations with exactly k inverse pairs.

5 min
dynamic-programming

K-diff Pairs in an Array: Hash Map for Target Differences

medium

How to solve LeetCode 532 K-diff Pairs in an Array. Use a frequency counter to find unique pairs with exactly k difference in O(n) time.

4 min
arrayshash-map

Freedom Trail: Ring DP with Position Tracking

hard

How to solve LeetCode 514 Freedom Trail using dynamic programming. Visual walkthrough of minimum rotation cost on a circular ring.

6 min
dynamic-programming

Fraction Addition and Subtraction: Parsing and Reducing Fractions

medium

How to solve LeetCode 592 Fraction Addition and Subtraction by parsing fraction strings and accumulating results with GCD reduction.

5 min
mathstrings

Find Largest Value in Each Tree Row: BFS Level Maximums

medium

How to solve LeetCode 515 Find Largest Value in Each Tree Row using BFS. Visual walkthrough of tracking maximums during level-order traversal.

5 min
trees

Find Duplicate File in System: Grouping by Content with Hash Maps

medium

How to solve LeetCode 609 Find Duplicate File in System by parsing directory strings and grouping files with identical content using a hash map.

4 min
arrayshash-map

Find Bottom Left Tree Value: BFS Level-by-Level

medium

How to solve LeetCode 513 Find Bottom Left Tree Value using BFS. Visual walkthrough of level-order traversal to find the leftmost value in the last row.

5 min
trees

Fibonacci Number: Bottom-Up Dynamic Programming

easy

How to solve LeetCode 509 Fibonacci Number using bottom-up dynamic programming. Visual walkthrough of the DP table approach.

4 min
dynamic-programming

Exclusive Time of Functions: Stack-Based Execution Tracking

medium

How to solve LeetCode 636 Exclusive Time of Functions using a stack to track nested function calls and compute exclusive execution times.

5 min
arraysstacks

Erect the Fence: Convex Hull with Monotone Chain

hard

How to solve LeetCode 587 Erect the Fence using Andrew's Monotone Chain algorithm to compute the convex hull. Visual walkthrough, Python solution, and O(n log n) complexity analysis.

6 min
math

Encode and Decode TinyURL: Hash Map Design with Random Keys

medium

How to solve LeetCode 535 Encode and Decode TinyURL. Design a URL shortening service using a bidirectional hash map with random key generation.

4 min
designhash-map

Distribute Candies: Sets, Limits, and One Line of Insight

easy

How to solve LeetCode 575 Distribute Candies using a set to count unique types and a simple min comparison.

5 min
arrayshash-map

Detect Capital: Counting Uppercase Letters

easy

How to solve LeetCode 520 Detect Capital by counting uppercase letters. One-pass O(n) solution with visual diagrams.

4 min
strings

Design Circular Queue: Array-Based Ring Buffer

medium

How to solve LeetCode 622 Design Circular Queue using a fixed-size array with front and rear pointers. Modular arithmetic handles the wrap-around.

6 min
designarrays

Delete Operation for Two Strings: Minimum Deletions via LCS

medium

How to solve LeetCode 583 Delete Operation for Two Strings with 2D DP. Find minimum deletions to make two strings equal using the longest common subsequence.

7 min
stringsdynamic-programming

Course Schedule III: Maximizing Courses with Greedy + Heap

hard

How to solve LeetCode 630 Course Schedule III using a greedy approach with a max-heap to maximize the number of courses you can take.

5 min
greedyheap

Convert BST to Greater Tree: Reverse Inorder Traversal

medium

How to solve LeetCode 538 Convert BST to Greater Tree. Use reverse inorder traversal to accumulate a running sum and update each node in-place.

4 min
trees

Continuous Subarray Sum: Prefix Sums Meet Modular Arithmetic

medium

How to solve LeetCode 523 Continuous Subarray Sum using prefix sums with modular arithmetic and a hash map. Visual walkthrough with step-by-step diagrams.

7 min
arrayshash-map

Contiguous Array: Finding Equal 0s and 1s with Prefix Sums

medium

How to solve LeetCode 525 Contiguous Array in O(n) using the 0-to-negative-1 trick, prefix sums, and a hash map. Visual walkthrough with step-by-step diagrams.

5 min
arrayshash-map

Construct String from Binary Tree: Preorder with Parentheses

medium

How to solve LeetCode 606 Construct String from Binary Tree using preorder traversal with selective parentheses for unambiguous representation.

5 min
treesstrings

Complex Number Multiplication: Parsing and Math

medium

How to solve LeetCode 537 Complex Number Multiplication. Parse the string format, apply the multiplication formula, and format the result.

4 min
mathstrings

Coin Change II: Counting Combinations with DP

medium

How to solve LeetCode 518 Coin Change II with bottom-up dynamic programming. Visual walkthrough of the unbounded knapsack counting pattern.

5 min
dynamic-programming

Can Place Flowers: Greedy Planting in a Flowerbed

easy

How to solve LeetCode 605 Can Place Flowers using a greedy scan to place flowers without violating adjacency rules.

5 min
arraysgreedy

Binary Tree Tilt: Post-Order DFS with Subtree Sums

easy

How to solve LeetCode 563 Binary Tree Tilt using post-order traversal to compute subtree sums and accumulate tilt values.

6 min
trees

Beautiful Arrangement: Backtracking with Divisibility Pruning

medium

How to solve LeetCode 526 Beautiful Arrangement using backtracking with divisibility checks. Visual decision tree and bitmask DP alternative explained.

6 min
backtrackingdynamic-programming

Array Partition: Greedy Pairing After Sorting

easy

How to solve LeetCode 561 Array Partition by sorting and pairing adjacent elements for maximum sum of minimums.

4 min
arrayssorting

Array Nesting: Finding the Longest Cycle in a Permutation

medium

How to solve LeetCode 565 Array Nesting by recognizing permutation cycles and using visited marking for O(n) time.

5 min
arrays

Add One Row to Tree: BFS Insertion at a Target Depth

medium

How to solve LeetCode 623. Use BFS to find nodes one level above the target depth, then insert a new row of nodes by rewiring children.

6 min
trees

01 Matrix: Multi-Source BFS for Nearest Zero

medium

How to solve LeetCode 542 01 Matrix using multi-source BFS to find the distance of each cell to its nearest zero in O(m*n) time.

7 min
arraysmatrix

Validate IP Address: Parsing IPv4 and IPv6

medium

How to solve LeetCode 468 Validate IP Address by splitting the string and checking each segment against IPv4 and IPv6 rules.

6 min
strings

Total Hamming Distance: Counting Bits Column by Column

medium

How to solve LeetCode 477 Total Hamming Distance by counting set bits at each position and multiplying ones by zeros.

5 min
bit-manipulationmath

Teemo Attacking: Merging Overlapping Intervals

easy

How to solve LeetCode 495 Teemo Attacking by calculating total poison duration with overlapping intervals. Visual walkthrough of the linear scan approach.

4 min
arrays

Target Sum: From Brute Force to Subset Sum DP

medium

How to solve LeetCode 494 Target Sum using DP. Visual walkthrough transforming the +/- assignment problem into a subset sum problem for an O(n*sum) solution.

5 min
arraysdynamic-programming

String Compression: Two Pointer In-Place Encoding

medium

How to solve LeetCode 443 String Compression using the two-pointer technique to compress characters in place.

5 min
stringstwo-pointers

Sort Characters By Frequency: Bucket Sort Approach

medium

How to solve LeetCode 451 Sort Characters By Frequency using hash map counting and bucket sort for O(n) time.

4 min
stringshash-map

Sliding Window Median: Two Heaps with Lazy Deletion

hard

How to solve LeetCode 480 Sliding Window Median using two heaps with lazy deletion. Find the median in every window of size k efficiently.

9 min
arraysheap

Serialize and Deserialize BST: Preorder with Bounds

medium

How to solve LeetCode 449 Serialize and Deserialize BST using preorder traversal and bound-based reconstruction.

6 min
treesdesign

Reverse Pairs: Merge Sort for Counting Inversions

hard

How to solve LeetCode 493 Reverse Pairs using modified merge sort. Visual walkthrough of counting pairs where nums[i] > 2 * nums[j] during the merge phase.

5 min
arraysbinary-search

Repeated Substring Pattern: The Double String Trick

easy

How to solve LeetCode 459 Repeated Substring Pattern using the string concatenation method.

4 min
strings

Relative Ranks: Sorting with Index Tracking

easy

How to solve LeetCode 506 Relative Ranks using sorting with original indices. Visual walkthrough of the rank assignment pattern.

5 min
arrayssorting

Reconstruct Original Digits from English: Letter Frequency Trick

medium

How to solve LeetCode 423 Reconstruct Original Digits from English using unique letter identification. Visual walkthrough of the frequency-based approach.

5 min
stringsmath

Predict the Winner: Game Theory DP

medium

How to solve LeetCode 486 Predict the Winner using interval DP. Visual walkthrough of the score-difference recurrence where dp[i][j] tracks the best advantage the current player can achieve.

5 min
dynamic-programming

Perfect Number: Divisor Sum with Square Root Optimization

easy

How to solve LeetCode 507 Perfect Number by finding divisors up to the square root. Visual walkthrough of the divisor-pair technique.

5 min
math

Path Sum III: Prefix Sum in Trees

medium

How to solve LeetCode 437 Path Sum III using prefix sums and DFS. Count all paths in a binary tree that sum to a target value.

8 min
trees

Ones and Zeroes: 2D Knapsack DP

medium

How to solve LeetCode 474 Ones and Zeroes using a two-dimensional knapsack dynamic programming approach.

6 min
dynamic-programming

Number of Segments in a String: Counting Words Without Split

easy

How to solve LeetCode 434 Number of Segments in a String by counting space-to-character transitions. Visual walkthrough of a clean one-pass approach.

5 min
strings

Number Complement: Flipping Bits with XOR

easy

How to solve LeetCode 476 Number Complement by building a bitmask and using XOR to flip all significant bits.

5 min
bit-manipulation

Non-overlapping Intervals: Greedy Interval Scheduling

medium

How to solve LeetCode 435 Non-overlapping Intervals using greedy interval scheduling. Visual walkthrough of sorting by end time and removing minimum overlapping intervals.

5 min
arraysgreedy

Non-decreasing Subsequences: Backtracking with Deduplication

medium

How to solve LeetCode 491 Non-decreasing Subsequences using backtracking with set-based deduplication. Visual walkthrough of building valid subsequences while avoiding duplicates.

6 min
arraysbacktracking

Next Greater Element II: Circular Array Stack Pattern

medium

How to solve LeetCode 503 Next Greater Element II using a monotonic stack on a circular array. Visual walkthrough of the doubled-traversal trick.

7 min
arraysstacks

Next Greater Element I: Stack + Hash Map Pattern

easy

How to solve LeetCode 496 Next Greater Element I using a monotonic stack and hash map. Visual walkthrough of the next-greater-element pattern.

6 min
arraysstacks

N-ary Tree Level Order Traversal: BFS Beyond Binary Trees

medium

How to solve LeetCode 429 N-ary Tree Level Order Traversal using BFS. Visual walkthrough of level-by-level processing with a queue.

5 min
trees

Most Frequent Subtree Sum: DFS with Frequency Counting

medium

How to solve LeetCode 508 Most Frequent Subtree Sum using post-order DFS and a hash map. Visual walkthrough of subtree sum collection.

6 min
treeshash-map

Minimum Number of Arrows to Burst Balloons: Greedy Interval Strategy

medium

How to solve LeetCode 452 Minimum Number of Arrows to Burst Balloons using greedy interval scheduling.

4 min
arraysgreedy

Minimum Moves to Equal Array Elements: The Decrement Trick

medium

How to solve LeetCode 453 Minimum Moves to Equal Array Elements using the mathematical equivalence between incrementing n-1 elements and decrementing one.

4 min
arraysmath

Minimum Moves to Equal Array Elements II: Why the Median Wins

medium

How to solve LeetCode 462 Minimum Moves to Equal Array Elements II using the median property for minimum absolute deviations.

5 min
arraysmath

Minimum Genetic Mutation: BFS on Gene Strings

medium

How to solve LeetCode 433 Minimum Genetic Mutation using BFS to find the shortest transformation sequence. Visual walkthrough of gene string graph traversal.

5 min
stringsgraph

Maximum XOR of Two Numbers in an Array: Bitwise Trie Approach

medium

How to solve LeetCode 421 Maximum XOR of Two Numbers in an Array using a bitwise trie. Visual walkthrough of greedy XOR maximization.

6 min
arraystrie

Max Consecutive Ones: Single Pass Counter

easy

How to solve LeetCode 485 Max Consecutive Ones with a single pass and two variables. Visual walkthrough, Python solution, and building blocks.

4 min
arrays

Matchsticks to Square: Backtracking with Pruning

medium

How to solve LeetCode 473 Matchsticks to Square using backtracking to partition matchsticks into four equal-sum groups.

10 min
arraysbacktracking

Magical String: Self-Describing Sequence Generation

medium

How to solve LeetCode 481 Magical String. Generate the self-describing sequence using its own content as instructions, then count the 1s in the first n characters.

5 min
strings

License Key Formatting: String Manipulation from the Right

easy

How to solve LeetCode 482 License Key Formatting by stripping dashes, uppercasing, and regrouping characters from the right. Visual walkthrough with Python code.

5 min
strings

LFU Cache: Frequency-Based Eviction in O(1)

hard

How to solve LeetCode 460 LFU Cache with O(1) get and put using hash maps and doubly linked lists per frequency.

7 min
designhash-map

Keyboard Row: Hash Map Row Lookup

easy

How to solve LeetCode 500 Keyboard Row using a hash map for row lookup. Visual walkthrough of the keyboard row pattern.

5 min
arrayshash-map

K-th Smallest in Lexicographical Order: Virtual Trie Traversal

hard

How to solve LeetCode 440 K-th Smallest in Lexicographical Order by counting nodes in a virtual trie without building it.

7 min
trie

Island Perimeter: Counting Edges Without DFS

easy

How to solve LeetCode 463 Island Perimeter by counting land cells and subtracting shared edges.

5 min
arraysmatrix

IPO: Greedy Selection with Two Heaps

hard

How to solve LeetCode 502 IPO using a greedy approach with a min-heap and max-heap. Visual walkthrough of the capital maximization pattern.

6 min
heapgreedy

Implement Rand10 Using Rand7: Rejection Sampling

medium

How to solve LeetCode 470 Implement Rand10() Using Rand7() with rejection sampling to generate uniform random numbers.

6 min
math

Heaters: Binary Search for Minimum Radius

medium

How to solve LeetCode 475 Heaters using sorting and binary search to find the minimum heating radius.

5 min
arraysbinary-search

Hamming Distance: XOR and Bit Counting

easy

How to solve LeetCode 461 Hamming Distance using XOR and Brian Kernighan's bit counting technique.

4 min
bit-manipulation

Flatten a Multilevel Doubly Linked List: DFS Pointer Manipulation

medium

How to solve LeetCode 430 Flatten a Multilevel Doubly Linked List using iterative DFS. Visual walkthrough of flattening nested linked list levels.

5 min
linked-lists

Find Right Interval: Binary Search on Sorted Starts

medium

How to solve LeetCode 436 Find Right Interval using sorted start points and binary search. Visual walkthrough of finding the minimum start that follows each interval's end.

4 min
arraysbinary-search

Find Mode in Binary Search Tree: Inorder Traversal Pattern

easy

How to solve LeetCode 501 Find Mode in Binary Search Tree using inorder traversal. Visual walkthrough of mode finding in a BST.

5 min
trees

Find All Numbers Disappeared in an Array: Index Marking

easy

How to solve LeetCode 448 Find All Numbers Disappeared in an Array using the index-marking technique in O(n) time and O(1) extra space.

5 min
arrays

Find All Duplicates in an Array: Index as Hash Map

medium

How to solve LeetCode 442 Find All Duplicates in an Array in O(n) time and O(1) space by using array indices as a hash map.

5 min
arrays

Find All Anagrams in a String: Sliding Window Frequency Match

medium

How to solve LeetCode 438 Find All Anagrams in a String using sliding window and character frequency maps.

6 min
stringssliding-window

Diagonal Traverse: Matrix Zigzag Pattern

medium

How to solve LeetCode 498 Diagonal Traverse with a simulation approach. Visual walkthrough of diagonal zigzag traversal in a matrix.

6 min
arraysmatrix

Delete Node in a BST: Three Cases of Tree Surgery

medium

How to solve LeetCode 450 Delete Node in a BST by handling the three deletion cases: leaf, one child, and two children.

5 min
trees

Construct the Rectangle: Finding the Closest Square

easy

How to solve LeetCode 492 Construct the Rectangle by searching downward from the square root. Visual walkthrough of finding dimensions closest to a square.

4 min
math

Concatenated Words: Word Break for Every Word

hard

How to solve LeetCode 472 Concatenated Words using dynamic programming word break applied to each candidate word.

6 min
stringsdynamic-programming

Circular Array Loop: Fast and Slow Pointers in a Ring

medium

How to solve LeetCode 457 Circular Array Loop using Floyd's cycle detection with direction constraints.

6 min
arraystwo-pointers

Battleships in a Board: Count Ships with One Pass

medium

How to solve LeetCode 419 Battleships in a Board using a single-pass O(1) space approach. Visual walkthrough of counting battleship heads.

5 min
arraysmatrix

Base 7: Number Base Conversion

easy

How to solve LeetCode 504 Base 7 by repeatedly dividing and collecting remainders. Visual walkthrough of base conversion.

5 min
math

Assign Cookies: Greedy Two-Pointer Matching

easy

How to solve LeetCode 455 Assign Cookies using greedy matching with sorted arrays and two pointers.

5 min
arraysgreedy

Arranging Coins: Binary Search on Triangular Numbers

easy

How to solve LeetCode 441 Arranging Coins using binary search to find the largest complete staircase row.

6 min
mathbinary-search

All O'one Data Structure: O(1) Inc, Dec, Max, Min

hard

How to solve LeetCode 432 All O'one Data Structure using a doubly-linked list with hash map for O(1) operations. Visual walkthrough of the bucket-based design.

6 min
designhash-map

Add Two Numbers II: Stack-Based Linked List Addition

medium

How to solve LeetCode 445 Add Two Numbers II using stacks to add linked list numbers without reversing.

5 min
linked-listsstacks

4Sum II: Hash Map Meet-in-the-Middle

medium

How to solve LeetCode 454 4Sum II using hash map pairwise sums and the meet-in-the-middle technique.

5 min
arrayshash-map

132 Pattern: Monotonic Stack from the Right

medium

How to solve LeetCode 456 132 Pattern using a monotonic decreasing stack traversed from right to left.

6 min
arraysstacks

Wiggle Subsequence (LeetCode 376): Greedy Peak-Valley Count

medium

How to solve LeetCode Wiggle Subsequence in O(n) time and O(1) space by counting alternating peaks and valleys with a greedy scan.

6 min
arraysgreedy

Wiggle Sort II: The Median Split Interleave

medium

How to solve LeetCode 324 by sorting, splitting at the median, then interleaving from the ends of each half to handle arrays with duplicate elements correctly.

5 min
arrayssorting

Verify Preorder Serialization of a Binary Tree: Slot Counting

medium

Solve LeetCode 331 by treating the serialization as a capacity problem: each node consumes one slot and opens two new ones, while each null leaf just consumes one.

5 min
stringsstacks

Valid Perfect Square: Binary Search Without sqrt()

easy

How to solve LeetCode 367 by running binary search on the candidate range instead of using any built-in sqrt function.

4 min
binary-searchmath

UTF-8 Validation: Bit Pattern Matching

medium

How to solve LeetCode 393 UTF-8 Validation. Check byte sequences against UTF-8 encoding rules using bit manipulation.

5 min
bit-manipulation

Third Maximum Number: Tracking Multiple Maximums

easy

How to solve LeetCode 414 Third Maximum Number by tracking three distinct maximums in a single pass. Visual walkthrough with edge case handling.

5 min
arrays

Super Ugly Number: Multi-Pointer DP with Custom Primes

medium

How to solve LeetCode 313 Super Ugly Number by maintaining one pointer per prime and always picking the minimum next candidate. Visual walkthrough of the n-way merge pattern.

4 min
mathdynamic-programming

Super Pow: Modular Exponentiation on Big Exponents

medium

How to solve LeetCode 372 by breaking the exponent digit by digit and applying modular arithmetic at every step.

4 min
math

Sum of Two Integers: Adding Without the + Operator

medium

How to solve LeetCode 371 by simulating binary addition with XOR for the sum bits and AND-shift for the carry.

5 min
bit-manipulation

Sum of Left Leaves: Recursive Tree Traversal

easy

How to solve LeetCode 404 by recursively identifying and summing left leaves in a binary tree.

4 min
trees

Split Array Largest Sum: Binary Search on the Answer

hard

How to solve LeetCode 410 Split Array Largest Sum using binary search on the answer space. Visual walkthrough of the greedy validation approach.

6 min
arraysbinary-search

Shuffle an Array: The Fisher-Yates Algorithm

medium

How to solve LeetCode 384 Shuffle an Array using the Fisher-Yates (Knuth) shuffle. A clean O(n) algorithm that guarantees every permutation is equally likely.

4 min
arrays

Russian Doll Envelopes: LIS with a Sorting Trick

hard

How to solve LeetCode 354 by reducing it to a Longest Increasing Subsequence problem. Covers the width-asc height-desc sort trick, patience sorting, and O(n log n) implementation.

5 min
dynamic-programmingbinary-search

Rotate Function: Math Pattern in Rotations

medium

How to solve LeetCode 396 Rotate Function. Derive each F(k) from F(k-1) using a simple recurrence.

5 min
arraysmath

Reverse Vowels of a String: Two Pointers with Conditional Swaps

easy

How to solve LeetCode 345 Reverse Vowels of a String. Two pointers that independently skip consonants before swapping. Python solution with step-by-step walkthrough.

4 min
stringstwo-pointers

Reverse String: Two-Pointer Swap In-Place

easy

How to solve LeetCode 344 Reverse String using two pointers and in-place swaps. Visual step-by-step walkthrough with Python code.

4 min
stringstwo-pointers

Remove K Digits: Monotonic Stack Greedy

medium

How to solve LeetCode 402 by using a monotonic stack to greedily remove the largest digits first to form the smallest possible number.

4 min
stringsstacks

Remove Duplicate Letters: Greedy Monotonic Stack

medium

How to solve LeetCode 316 by combining a monotonic stack with a last-occurrence map to build the lexicographically smallest result with no duplicate letters.

4 min
stringsstacks

Reconstruct Itinerary: Hierholzer's Eulerian Path

hard

Solve LeetCode 332 by finding an Eulerian path in a directed graph using DFS with post-order insertion, always choosing the lexicographically smallest destination first.

7 min
graph

Random Pick Index: Reservoir Sampling

medium

How to solve LeetCode 398 Random Pick Index using reservoir sampling. Pick a random index with equal probability in one pass.

6 min
mathhash-map

Queue Reconstruction by Height: Greedy Insertion

medium

How to solve LeetCode 406 by sorting people by height descending and inserting each person at their k-index position.

4 min
arraysgreedy

Power of Three: Loop vs. Math

easy

Two ways to solve LeetCode 326: the iterative division loop and the elegant log-based math check, with a clear explanation of when each approach breaks.

6 min
math

Power of Four

easy

How to solve LeetCode 342 Power of Four using bit manipulation. A number is a power of four if it's a power of two with its single bit in an even bit position.

6 min
bit-manipulationmath

Odd Even Linked List: Two-Group Partition

medium

Solve LeetCode 328 in O(n) time and O(1) space by weaving two sub-lists through the original nodes, then splicing the even head onto the odd tail.

5 min
linked-lists

Nth Digit: Math Pattern Recognition

medium

How to solve LeetCode 400 Nth Digit by counting digits in number ranges. Find which number and which digit within it.

5 min
math

Minimum Height Trees: Topological Trimming to Find the Center

medium

How to solve LeetCode 310 by repeatedly pruning leaf nodes to find the 1 or 2 center nodes that minimize tree height. Visual walkthrough of the BFS leaf-trimming approach.

5 min
treesgraph

Mini Parser: Stack-Based Nested List Deserializer

medium

How to solve LeetCode 385 Mini Parser using a stack to parse a nested integer string into a recursive data structure.

4 min
stringsstacks

Maximum Product of Word Lengths: Bitmask Intersection

medium

How to solve LeetCode 318 using bitmasks to represent letter sets in O(1) space per word, then checking all pairs in O(n^2) time with a single bitwise AND.

4 min
stringsbit-manipulation

Max Sum of Rectangle No Larger Than K: 2D to 1D with Binary Search

hard

How to solve LeetCode 363 by fixing column boundaries, compressing to a 1D prefix sum problem, and using a sorted set with binary search to find the best subarray sum within k.

7 min
arraysbinary-search

Longest Substring with At Least K Repeating Characters

medium

How to solve LeetCode 395 with divide and conquer. Split on characters that appear fewer than k times.

6 min
stringssliding-window

Longest Increasing Path in a Matrix: DFS with Memoization

hard

Solve LeetCode 329 by running DFS from every cell, caching each cell's longest path length so you never recompute the same subproblem twice.

8 min
dynamic-programminggraph

Longest Absolute File Path: Stack-Based Depth Tracking

medium

How to solve LeetCode 388 Longest Absolute File Path using a hash map to track path lengths at each depth level.

4 min
stringsstacks

Linked List Random Node: Reservoir Sampling in One Pass

medium

How to solve LeetCode 382 by using reservoir sampling to pick a random node from a linked list with equal probability, without knowing the list length.

6 min
linked-listsmath

Lexicographical Numbers: DFS Without a Tree

medium

How to solve LeetCode 386 Lexicographical Numbers by treating 1-n as a virtual trie and walking it with DFS.

5 min
trees

Largest Divisible Subset: LIS Applied to Divisibility

medium

How to solve LeetCode 368 by sorting and running a longest-increasing-subsequence style DP on divisibility chains.

4 min
dynamic-programmingsorting

Kth Smallest Element in a Sorted Matrix (LeetCode 378): Binary Search on Value Space

medium

Learn how to solve LeetCode 378 using binary search on value space and an O(n) two-pointer count. Includes Python solution, step-by-step diagrams, and complexity breakdown.

6 min
arraysbinary-search

Is Subsequence: Two-Pointer Matching

easy

How to solve LeetCode 392 Is Subsequence with two pointers. Match characters in order without rearranging.

6 min
stringstwo-pointers

Intersection of Two Arrays: Set Lookup for Unique Common Elements

easy

How to solve LeetCode 349 Intersection of Two Arrays in O(m+n) using hash sets. Step-by-step walkthrough with visuals.

5 min
arrayshash-map

Intersection of Two Arrays II: Frequency Counting for Duplicate-Aware Intersection

easy

How to solve LeetCode 350 using a frequency counter. Handles duplicates correctly, with step-by-step visuals, complexity analysis, and interview follow-ups.

5 min
arrayshash-map

Integer Replacement: Greedy Bit Manipulation

medium

How to solve LeetCode 397 Integer Replacement using greedy bit analysis. Choose between n+1 and n-1 for odd numbers based on trailing bits.

7 min
mathdynamic-programming

Integer Break: The Math Insight That Makes DP Click

medium

How to solve LeetCode 343 Integer Break using the 3s insight and a clean DP approach. Visual walkthrough with step-by-step table build-up.

6 min
mathdynamic-programming

Insert Delete GetRandom O(1): Array + HashMap Combo

medium

How to solve LeetCode 380 by pairing a dynamic array with a hash map so that insert, delete, and getRandom all run in average O(1) time.

4 min
arrayshash-map

Insert Delete GetRandom O(1) - Duplicates Allowed

hard

How to solve LeetCode 381 by pairing a dynamic array with a hash map from values to sets of indices, enabling O(1) insert, remove, and getRandom with duplicate support.

5 min
arrayshash-map

Increasing Triplet Subsequence

medium

Learn how a two-pointer greedy approach solves LeetCode 334 in O(n) time and O(1) space by tracking just two sentinel values.

4 min
arraysgreedy

House Robber III: Tree DP

medium

How to solve LeetCode 337 House Robber III using post-order tree DP. Each node returns a (rob, skip) pair and the answer propagates from leaves to root.

5 min
treesdynamic-programming

Guess Number Higher or Lower (LeetCode 374): Binary Search on a Hidden Target

easy

Learn how to solve LeetCode 374 Guess Number Higher or Lower using binary search. Step-by-step visual walkthrough of narrowing a range with a guessing API.

5 min
binary-search

Guess Number Higher or Lower II (LeetCode 375): Minimax DP

medium

How to solve LeetCode 375 with interval DP and minimax thinking. Walk through how dp[i][j] is built and why picking the midpoint minimizes your worst-case cost.

5 min
dynamic-programming

Frog Jump: Dynamic Programming with Jump States

hard

How to solve LeetCode 403 by tracking possible jump sizes at each stone position using a hash map of sets.

5 min
dynamic-programming

Flatten Nested List Iterator

medium

How to solve LeetCode 341 Flatten Nested List Iterator using a stack. Lazily flatten nested lists as you go, avoiding upfront work on the entire structure.

5 min
stacksdesign

Fizz Buzz: The Classic Interview Warm-Up

easy

How to solve LeetCode 412 Fizz Buzz cleanly. Why this simple problem reveals important coding habits and how to handle multiple conditions elegantly.

4 min
mathstrings

First Unique Character in a String: Frequency Counting

easy

How to solve LeetCode 387 First Unique Character in a String using a hash map to count character frequencies.

4 min
stringshash-map

Find the Difference: XOR to Spot the Extra Character

easy

How to solve LeetCode 389 Find the Difference using XOR bit manipulation to identify the added character in O(1) space.

3 min
stringshash-map

Find K Pairs with Smallest Sums: Min-Heap on Sorted Pairs

medium

How to solve LeetCode 373 by seeding a min-heap with the first element of each row and expanding lazily to find the k smallest pair sums.

4 min
arraysheap

Evaluate Division: Graph Traversal with Weighted Edges

medium

How to solve LeetCode 399 Evaluate Division by building a weighted graph and using BFS to find paths between variables.

6 min
graph

Elimination Game: Tracking the Head Through Alternating Passes

medium

How to solve LeetCode 390 Elimination Game by tracking the head position through alternating left-to-right and right-to-left elimination passes.

4 min
math

Design Twitter: Merge K Sorted Lists with a Heap

medium

How to solve LeetCode 355 by modeling the newsfeed as a merge of per-user tweet lists. Covers the heap-based approach, data structure choices, and follow/unfollow semantics.

6 min
designhash-map

Decode String: Stack-Based String Building

medium

How to solve LeetCode 394 Decode String using a stack. Handle nested brackets and repeat counts step by step.

7 min
stringsstacks

Data Stream as Disjoint Intervals: Sorted Interval Merging

hard

How to solve LeetCode 352 by maintaining a sorted list of disjoint intervals. Covers the merge-on-insert approach, Python SortedList implementation, and complexity tradeoffs.

5 min
designarrays

Counting Bits

easy

How to solve LeetCode 338 Counting Bits in O(n) time and space using dynamic programming. Each number's bit count depends on the number with its lowest bit cleared.

6 min
dynamic-programmingbit-manipulation

Count of Smaller Numbers After Self: Binary Indexed Tree Explained

hard

How to solve LeetCode 315 by processing elements right to left with a Binary Indexed Tree (Fenwick Tree) to count smaller elements in O(n log n) time.

4 min
arraysbinary-search

Count Numbers with Unique Digits: Combinatorics with Digit DP

medium

How to solve LeetCode 357 by counting k-digit numbers with all distinct digits. Covers the slot-counting argument, the descending choices pattern, and iterative accumulation.

4 min
mathdynamic-programming

Convert a Number to Hexadecimal: Bit Masking

easy

How to solve LeetCode 405 by extracting 4 bits at a time with masking and shifting to build the hexadecimal string.

4 min
mathbit-manipulation

Combination Sum IV (LeetCode 377): Count All Ordered Combinations

medium

How to solve LeetCode 377 Combination Sum IV with bottom-up dynamic programming. Visual DP table walkthrough with step-by-step breakdown.

5 min
dynamic-programming

Burst Balloons: Interval DP with the Last-Burst Trick

hard

How to solve LeetCode 312 Burst Balloons using interval DP. The key insight is thinking about which balloon to burst LAST in each subinterval, not first.

5 min
dynamic-programming

Bulb Switcher: Why Only Perfect Squares Stay On

medium

LeetCode 319 reduces to counting perfect squares up to n. Understand why each bulb toggles once per divisor, and why only perfect squares have an odd divisor count.

4 min
math

Binary Watch: Bit Counting Enumeration

easy

How to solve LeetCode 401 Binary Watch by counting set bits across all valid hour and minute combinations.

5 min
backtrackingbit-manipulation

Best Time to Buy and Sell Stock with Cooldown: State Machine DP

medium

How to solve LeetCode 309 with a three-state DP machine: held, sold, and rest. Visual walkthrough of the state transitions and recurrence.

4 min
dynamic-programming

Arithmetic Slices: Counting Arithmetic Subarrays

medium

How to solve LeetCode 413 Arithmetic Slices with a simple DP counter. Visual walkthrough of counting contiguous arithmetic subsequences.

5 min
arraysdynamic-programming

Additive Number: Backtracking Through Numeric Strings

medium

How to solve LeetCode 306 Additive Number by splitting a string into a valid Fibonacci-like sequence. Visual walkthrough of the backtracking approach.

7 min
stringsbacktracking

Add Strings: Digit-by-Digit Addition Without Converting

easy

How to solve LeetCode 415 Add Strings by simulating grade-school addition. Visual walkthrough of the carry-based digit processing approach.

5 min
stringsmath

Word Pattern: Bidirectional Hash Map Matching

easy

How to solve LeetCode 290 Word Pattern using two hash maps for bijective mapping. O(n) solution with visual diagrams.

4 min
stringshash-map

Remove Invalid Parentheses: BFS Approach Explained

hard

How to solve LeetCode 301 Remove Invalid Parentheses using BFS. Visual walkthrough of finding all valid strings with minimum removals.

7 min
stringsbacktracking

Range Sum Query Immutable: Prefix Sums Explained

easy

How to solve LeetCode 303 Range Sum Query Immutable using prefix sums. Visual walkthrough of precomputing cumulative sums for O(1) range queries.

6 min
arraysdynamic-programming

Range Sum Query 2D Immutable: 2D Prefix Sums Explained

medium

How to solve LeetCode 304 Range Sum Query 2D Immutable using 2D prefix sums. Visual walkthrough of the inclusion-exclusion principle for O(1) rectangular region queries.

7 min
arraysmatrix

Peeking Iterator: Wrapper Pattern for Look-Ahead

medium

How to solve LeetCode 284 Peeking Iterator by wrapping an iterator with a cached peek value. Clean Python solution with visual diagrams.

5 min
design

Nim Game: The Power of Modulo 4

easy

How to solve LeetCode 292 Nim Game with a single line of code. Mathematical proof of the n % 4 strategy with visual diagrams.

4 min
math

Game of Life: In-Place State Encoding

medium

How to solve LeetCode 289 Game of Life in-place using state encoding. O(m*n) solution with visual diagrams explaining the transition rules.

5 min
arraysmatrix

Find the Duplicate Number: Floyd's Cycle Detection

medium

How to solve LeetCode 287 Find the Duplicate Number using Floyd's tortoise and hare algorithm. O(n) time, O(1) space solution with visual diagrams.

6 min
arraystwo-pointers

Find Median from Data Stream: Two Heaps Explained

hard

How to solve LeetCode 295 Find Median from Data Stream using two heaps. Visual walkthrough of maintaining a running median with a max-heap and min-heap.

7 min
heapdesign

Bulls and Cows: Hash Map Counting Explained

medium

How to solve LeetCode 299 Bulls and Cows using hash map counting. Visual walkthrough of matching exact and misplaced digits in one pass.

8 min
stringshash-map

Word Break II: All Valid Sentences with Backtracking

hard

How to solve LeetCode 140 Word Break II using backtracking with memoization. Find every way to split a string into dictionary words.

6 min
stringsdynamic-programming

Two Sum II: Converging Two Pointers on a Sorted Array

medium

How to solve LeetCode 167 Two Sum II using converging two pointers in O(n) time and O(1) space. Visual walkthrough and building blocks.

6 min
arraystwo-pointers

The Skyline Problem: Sweep Line with a Max Heap

hard

How to solve LeetCode 218 The Skyline Problem using a sweep line and max heap. O(n log n) solution explained with visual diagrams.

6 min
arraysheap

Summary Ranges: Grouping Consecutive Numbers

easy

How to solve LeetCode 228 Summary Ranges by scanning for consecutive groups. O(n) solution with visual walkthrough.

4 min
arrays

Sort List: Merge Sort on a Linked List

medium

How to solve LeetCode 148 Sort List using merge sort with slow/fast pointer splitting and recursive merge. O(n log n) time solution explained with visual walkthrough.

5 min
linked-listssorting

Sliding Window Maximum: Monotonic Deque Mastery

hard

How to solve LeetCode 239 Sliding Window Maximum using a monotonic deque. Find the max in every window of size k in O(n) time.

7 min
arraysstacks

Single Number: XOR Cancellation in One Pass

easy

How to solve LeetCode 136 Single Number using XOR. Pairs cancel to zero, leaving the lone element. O(n) time, O(1) space.

3 min
arraysbit-manipulation

Single Number III: Finding Two Unique Numbers with XOR

medium

How to solve LeetCode 260 Single Number III. Find two numbers that appear exactly once when every other number appears twice, using bit manipulation.

5 min
bit-manipulation

Single Number II: Bit Counting Modulo 3

medium

How to solve LeetCode 137 Single Number II. Count bits at each position modulo 3 to find the element that appears once, or use a ones/twos state machine for constant space.

6 min
arraysbit-manipulation

Shortest Palindrome: KMP Trick for Palindromic Prefixes

hard

How to solve LeetCode 214 Shortest Palindrome using the KMP failure function. O(n) solution explained with visual diagrams.

5 min
strings

Search a 2D Matrix II: The Staircase Search

medium

How to solve LeetCode 240 Search a 2D Matrix II. Use the sorted structure to eliminate a row or column at each step in O(m+n) time.

7 min
arraysbinary-search

Reverse Words in a String: Split, Reverse, Join

medium

How to solve LeetCode 151 Reverse Words in a String. Two approaches: split-reverse-join and in-place reversal. Python solutions with walkthrough.

5 min
strings

Reverse Bits: Bit-by-Bit Reversal

easy

How to solve LeetCode 190 Reverse Bits. Iterate 32 times, extracting the LSB and building the reversed result with shifts and OR. O(1) time, O(1) space.

4 min
bit-manipulation

Repeated DNA Sequences: Sliding Window with a Hash Set

medium

How to solve LeetCode 187 Repeated DNA Sequences using a fixed-size sliding window and hash set. O(n) solution with visual walkthrough.

6 min
stringshash-map

Remove Linked List Elements: Dummy Head Deletion

easy

How to solve LeetCode 203 Remove Linked List Elements. Visual walkthrough of using a dummy head node and prev pointer to safely delete nodes by value.

5 min
linked-lists

Rectangle Area: Computing Overlap Between Two Rectangles

medium

How to solve LeetCode 223 Rectangle Area by computing overlap. Clean visual approach with Python solution.

3 min
math

Power of Two: Bit Manipulation One-Liner

easy

How to solve LeetCode 231 Power of Two using bit manipulation. O(1) solution with visual walkthrough of the n & (n-1) trick.

5 min
bit-manipulation

Perfect Squares: Dynamic Programming with Square Numbers

medium

How to solve LeetCode 279 Perfect Squares with bottom-up DP. Visual table walkthrough showing the unbounded knapsack pattern with perfect squares.

4 min
dynamic-programming

Number of Digit One: Counting by Position

hard

How to solve LeetCode 233 Number of Digit One by analyzing each digit position. O(log n) solution with visual walkthrough.

5 min
math

Move Zeroes: Two Pointers for In-Place Partitioning

easy

How to solve LeetCode 283 Move Zeroes using two pointers. Visual walkthrough of the swap technique that preserves relative order.

4 min
arraystwo-pointers

Missing Number: XOR and Math Approaches

easy

How to solve LeetCode 268 Missing Number. Find the missing number in an array containing n distinct numbers from 0 to n using XOR or sum.

5 min
arraysbit-manipulation

Minimum Size Subarray Sum: Sliding Window in Action

medium

How to solve LeetCode 209 Minimum Size Subarray Sum with a sliding window. Visual walkthrough of expanding and shrinking windows.

5 min
arrayssliding-window

Maximum Gap: Bucket Sort for Linear Time

medium

How to solve LeetCode 164 Maximum Gap in O(n) time using bucket sort and the pigeonhole principle. Visual walkthrough of the bucket approach.

6 min
arrayssorting

Max Points on a Line: Slope Counting with GCD

hard

How to solve LeetCode 149 Max Points on a Line by normalizing slopes with GCD and counting per-anchor matches in a hash map. O(n^2) time, O(n) space.

7 min
mathhash-map

Majority Element II: Boyer-Moore Voting for n/3 Threshold

medium

How to solve LeetCode 229 Majority Element II using extended Boyer-Moore voting. O(n) time, O(1) space solution with visual walkthrough.

5 min
arrays

Lowest Common Ancestor of a BST: Leverage the Sorted Structure

medium

How to solve LeetCode 235 Lowest Common Ancestor of a Binary Search Tree. Use the BST property to find the fork point in O(h) time.

6 min
trees

Kth Smallest Element in a BST: Inorder Traversal Counting

medium

How to solve LeetCode 230 Kth Smallest Element in a BST using inorder traversal. O(H + k) solution with visual walkthrough.

5 min
trees

Isomorphic Strings: Character Mapping with Hash Maps

easy

How to solve LeetCode 205 Isomorphic Strings using two hash maps. Visual walkthrough of bidirectional character mapping.

6 min
stringshash-map

Intersection of Two Linked Lists: Two-Pointer Length Equalization

easy

How to solve LeetCode 160 Intersection of Two Linked Lists using the two-pointer length equalization technique. O(m+n) time, O(1) space solution explained with visual walkthrough.

6 min
linked-lists

Integer to English Words: Breaking Numbers into Groups

hard

How to solve LeetCode 273 Integer to English Words. Convert a non-negative integer to its English words representation by processing three-digit groups.

6 min
stringsmath

Insertion Sort List: Sorting a Linked List In Place

medium

How to solve LeetCode 147 Insertion Sort List using a dummy head and sorted-portion insertion. O(n^2) time, O(1) space solution with visual walkthrough and building blocks.

5 min
linked-listssorting

Implement Stack using Queues: LIFO from FIFO

easy

How to solve LeetCode 225 Implement Stack using Queues. Build a stack from a single queue with O(n) push.

4 min
stacksdesign

House Robber II: Circular DP

medium

How to solve LeetCode 213 House Robber II with dynamic programming on a circular street. Visual walkthrough of the two-pass approach.

5 min
dynamic-programming

H-Index: Sorting to Find Your Citation Threshold

medium

How to solve LeetCode 274 H-Index using sorting. Visual walkthrough of the counting approach and why sorting simplifies the logic.

4 min
arrayssorting

H-Index II: Binary Search on a Sorted Array

medium

How to solve LeetCode 275 H-Index II with binary search in O(log n) time. Visual walkthrough of the search space and why it works.

4 min
arraysbinary-search

Fraction to Recurring Decimal: Long Division with Cycle Detection

medium

How to solve LeetCode 166 Fraction to Recurring Decimal. Simulate long division and use a hash map to detect repeating remainders, producing the exact decimal string with parentheses around the repeating cycle.

4 min
mathhash-map

First Bad Version: Binary Search at Its Simplest

easy

How to solve LeetCode 278 First Bad Version with binary search. Visual walkthrough of halving the search space to find the boundary.

5 min
binary-search

Find Minimum in Rotated Sorted Array II: Handling Duplicates

hard

How to solve LeetCode 154 Find Minimum in Rotated Sorted Array II. Same binary search pivot logic, but duplicates create ambiguity that requires a linear shrink fallback.

6 min
arraysbinary-search

Factorial Trailing Zeroes: Counting Factors of Five

medium

How to solve LeetCode 172 Factorial Trailing Zeroes in O(log n) time by counting factors of 5. No need to compute the factorial itself.

4 min
math

Excel Sheet Column Title: Base-26 Conversion

easy

How to solve LeetCode 168 Excel Sheet Column Title. Convert a column number to its letter title using a modified base-26 loop that subtracts 1 before each mod to handle 1-indexed letters.

5 min
mathstrings

Excel Sheet Column Number: Base-26 to Integer

easy

How to solve LeetCode 171 Excel Sheet Column Number. Convert an Excel column title like 'ZY' to its column number 701 using Horner's method for base-26 evaluation, processing one character at a time left to right.

4 min
mathstrings

Dungeon Game: Reverse DP for Minimum Health

hard

How to solve LeetCode 174 Dungeon Game with reverse dynamic programming. Fill the DP table from bottom-right to top-left to find the minimum initial health needed.

7 min
dynamic-programmingmatrix

Different Ways to Add Parentheses: Divide and Conquer Expressions

medium

How to solve LeetCode 241 Different Ways to Add Parentheses. Split at each operator, solve sub-problems recursively, and combine all possible results.

5 min
mathdynamic-programming

Delete Node in a Linked List: The Copy-and-Skip Trick

medium

How to solve LeetCode 237 Delete Node in a Linked List. Delete a node when you only have access to that node, not the head.

4 min
linked-lists

Course Schedule II: Topological Sort with BFS

medium

How to solve LeetCode 210 Course Schedule II using topological sort. Visual walkthrough of Kahn's algorithm for finding course ordering.

7 min
graph

Count Primes: The Sieve of Eratosthenes

medium

How to solve LeetCode 204 Count Primes using the Sieve of Eratosthenes. Visual walkthrough of prime counting with O(n log log n) time.

6 min
math

Count Complete Tree Nodes: Binary Search on a Tree

medium

How to solve LeetCode 222 Count Complete Tree Nodes in O(log^2 n) using tree height checks. Visual walkthrough and clean Python solution.

5 min
treesbinary-search

Contains Duplicate III: Bucket Sort for Value Ranges

hard

How to solve LeetCode 220 Contains Duplicate III using bucket sort. O(n) solution explained with visual diagrams.

5 min
arrayssliding-window

Contains Duplicate II: Sliding Window with a Hash Map

easy

How to solve LeetCode 219 Contains Duplicate II using a hash map or sliding window set. O(n) solution explained with visual diagrams.

5 min
arrayshash-map

Compare Version Numbers: Split and Compare Revisions

medium

How to solve LeetCode 165 Compare Version Numbers. Split version strings by dot, convert revisions to integers, and compare revision by revision with zero-padding for missing parts.

4 min
strings

Combination Sum III: Backtracking with Fixed Size

medium

How to solve LeetCode 216 Combination Sum III using backtracking with pruning. Clean Python solution with visual walkthrough.

7 min
backtracking

Bitwise AND of Numbers Range: Common Prefix of Binary Representations

medium

How to solve LeetCode 201 Bitwise AND of Numbers Range. Find the common binary prefix of left and right by shifting both until they match, then shift back. O(log n) time, O(1) space.

4 min
bit-manipulation

Binary Tree Right Side View: Last Node at Each Level

medium

How to solve LeetCode 199 with BFS. Process each level of the tree with a queue and keep only the last node at each level to build the right side view.

5 min
trees

Binary Tree Preorder Traversal: Root, Left, Right

easy

How to solve LeetCode 144 Binary Tree Preorder Traversal with recursive and iterative stack-based approaches. Visual walkthrough of both solutions.

6 min
trees

Binary Tree Postorder Traversal: Left, Right, Root

easy

How to solve LeetCode 145 Binary Tree Postorder Traversal with recursive and iterative approaches. Visual walkthrough of the reversed modified preorder technique.

5 min
trees

Binary Tree Paths: DFS Path Building

easy

How to solve LeetCode 257 Binary Tree Paths. Find all root-to-leaf paths in a binary tree using depth-first search and string building.

5 min
trees

Binary Search Tree Iterator: Controlled Inorder with a Stack

medium

How to solve LeetCode 173 Binary Search Tree Iterator using a stack to lazily traverse the left spine. Visual walkthrough of next() and hasNext() with O(1) amortized time and O(h) space.

5 min
treesstacks

Basic Calculator: Stack-Based Expression Evaluation

hard

How to solve LeetCode 224 Basic Calculator using a stack for parentheses. O(n) solution with visual walkthrough.

5 min
stacksmath

Basic Calculator II: Stack-Based Operator Precedence

medium

How to solve LeetCode 227 Basic Calculator II using a stack for operator precedence. O(n) solution with visual walkthrough.

5 min
stacksmath

Add Digits: The Digital Root Formula

easy

How to solve LeetCode 258 Add Digits. Reduce a number to a single digit by repeatedly summing its digits, with an O(1) math solution.

5 min
math

Word Ladder II: All Shortest Transformation Paths

hard

How to solve LeetCode 126 Word Ladder II. Use BFS to build a distance map, then DFS backtracking to recover all shortest transformation sequences.

6 min
graphbacktracking

Wildcard Matching: DP with ? and * Patterns

hard

How to solve LeetCode 44 Wildcard Matching with 2D dynamic programming. Handle '?' single-char and '*' multi-char wildcards with a boolean DP table.

8 min
stringsdynamic-programming

Valid Sudoku: Hash Set Validation

medium

How to solve LeetCode Valid Sudoku by using hash sets to track seen digits per row, column, and 3x3 box. Box indexing with floor division explained.

7 min
arrayshash-map

Unique Paths II: DP with Obstacles

medium

How to solve LeetCode 63 Unique Paths II with dynamic programming. Handle obstacles in a grid by setting blocked cells to zero in your DP table.

6 min
dynamic-programmingmatrix

Unique Binary Search Trees: Catalan Numbers and DP

medium

How to solve LeetCode 96 Unique Binary Search Trees with bottom-up DP. Visual walkthrough of the Catalan number recurrence and root-splitting strategy.

5 min
treesdynamic-programming

Unique Binary Search Trees II: Generate All Valid BSTs

medium

How to solve LeetCode 95 by recursively generating all structurally unique BSTs for values 1 to n. Full walkthrough with visuals.

6 min
treesdynamic-programming

Triangle: Bottom-Up DP for Minimum Path Sum

medium

How to solve LeetCode 120 Triangle with bottom-up dynamic programming. Start from the last row, reduce upward, and get O(n) space.

6 min
arraysdynamic-programming

Sum Root to Leaf Numbers: Building Numbers Top-Down

medium

How to solve LeetCode 129 Sum Root to Leaf Numbers. Use pre-order DFS to build numbers digit by digit from root to leaf, then sum them all.

6 min
trees

Sudoku Solver: Backtracking with Constraint Checking

hard

How to solve LeetCode 37 Sudoku Solver using backtracking with row, column, and box constraint sets. The classic constraint satisfaction problem on a grid.

11 min
backtrackingmatrix

Subsets II: Backtracking Without Duplicate Subsets

medium

How to solve LeetCode 90 Subsets II using sorted backtracking with same-level duplicate skipping. Visual recursion tree showing pruned branches and step-by-step walkthrough.

7 min
arraysbacktracking

Sqrt(x): Binary Search for the Integer Square Root

easy

How to solve LeetCode 69 Sqrt(x) using binary search on the answer space. Search for the largest integer whose square fits within x.

6 min
binary-searchmath

Spiral Matrix II: Filling a Matrix in Spiral Order

medium

How to solve LeetCode 59 Spiral Matrix II by filling an n x n grid with values 1 to n squared in spiral order using boundary shrinking.

5 min
arraysmatrix

Simplify Path: Stack-Based Directory Navigation

medium

How to solve LeetCode 71 Simplify Path using a stack. Split by slash, filter tokens, and rebuild the canonical Unix path.

6 min
stringsstacks

Search in Rotated Sorted Array II: Handling Duplicates

medium

How to solve LeetCode 81 Search in Rotated Sorted Array II. Same modified binary search, but duplicates create an ambiguous case that requires shrinking both ends.

6 min
arraysbinary-search

Search a 2D Matrix: Binary Search on a Flattened Grid

medium

How to solve LeetCode 74 Search a 2D Matrix in O(log(m*n)) time. Treat the matrix as a virtual 1D sorted array and run binary search with index mapping.

6 min
arraysbinary-search

Same Tree: Recursive Structure Comparison

easy

How to solve LeetCode 100 Same Tree by recursively comparing two binary trees in parallel. Visual walkthrough with Python solution.

5 min
trees

Rotate List: Circular Linked List Rotation

medium

How to solve LeetCode 61 Rotate List by making the list circular and breaking it at the right position. Visual walkthrough with Python solution.

5 min
linked-lists

Reverse Linked List II: Reverse a Sublist in One Pass

medium

How to solve LeetCode 92 Reverse Linked List II. Visual walkthrough of reversing a sublist in place using a dummy head and the move-to-front technique.

5 min
linked-lists

Restore IP Addresses: Backtracking with Constraints

medium

How to solve LeetCode 93 Restore IP Addresses using backtracking. Partition a digit string into four valid segments (0-255, no leading zeros) and prune invalid branches early.

9 min
stringsbacktracking

Remove Duplicates from Sorted List: Keep One of Each

easy

How to solve LeetCode 83 Remove Duplicates from Sorted List. Visual walkthrough of in-place linked list deduplication with a single pointer.

4 min
linked-lists

Remove Duplicates from Sorted List II: Delete All Duplicated Nodes

medium

How to solve LeetCode 82 by using a dummy head and prev pointer to skip over all nodes with duplicate values. O(n) time, O(1) space.

5 min
linked-lists

Remove Duplicates from Sorted Array II: Allow At Most Two

medium

How to solve LeetCode 80 using a write pointer with lookback comparison to allow at most two duplicates in-place. Visual walkthrough, Python solution, and building blocks.

4 min
arraystwo-pointers

Recover Binary Search Tree: Find and Fix Two Swapped Nodes

medium

How to solve LeetCode 99 Recover Binary Search Tree by finding two swapped nodes using inorder traversal violation detection. O(n) time, O(h) space.

6 min
trees

Pow(x, n): Fast Exponentiation by Squaring

medium

How to solve LeetCode 50 Pow(x, n) using binary exponentiation. Halve the exponent at each step for O(log n) time instead of O(n) brute force.

5 min
math

Populating Next Right Pointers: Level-by-Level Linking

medium

How to solve LeetCode 116 with O(1) space. Use already-established next pointers from the previous level to traverse and link each node to its right neighbor.

5 min
trees

Populating Next Right Pointers II: Handling Non-Perfect Trees

medium

How to solve LeetCode 117 using a dummy node to build next-level linked lists in O(1) space. Handle any binary tree, not just perfect ones.

7 min
trees

Plus One: Handling Carry in Array Arithmetic

easy

How to solve LeetCode 66 Plus One by traversing an array from right to left with carry propagation. A clean introduction to in-place digit manipulation.

5 min
arraysmath

Permutations II: Backtracking with Duplicate Handling

medium

How to solve LeetCode 47 Permutations II using sorted backtracking with a used array and same-level duplicate skipping. Visual recursion tree with pruned branches.

7 min
arraysbacktracking

Permutation Sequence: The Factorial Number System

hard

How to solve LeetCode 60 Permutation Sequence in O(n^2) time without generating all permutations. Use the factorial number system to jump directly to the kth permutation.

6 min
mathbacktracking

Path Sum II: Collecting All Valid Root-to-Leaf Paths

medium

How to solve LeetCode 113 Path Sum II with DFS and backtracking. Track paths, subtract node values, collect results at leaves where the remainder is zero.

7 min
treesbacktracking

Pascal's Triangle: Row-by-Row Construction

easy

How to solve LeetCode 118 Pascal's Triangle by building each row iteratively. A clean introduction to the neighbor sum pattern.

5 min
arraysdynamic-programming

Pascal's Triangle II: Single Row in O(k) Space

easy

How to solve LeetCode 119 Pascal's Triangle II by building the target row in place with reverse iteration. O(k) time, O(k) space.

5 min
arraysdynamic-programming

Partition List: Two-Pointer Split and Reconnect

medium

How to solve LeetCode 86 Partition List using dual dummy-headed lists. O(n) time, O(1) space solution with visual walkthrough and building blocks.

5 min
linked-lists

Palindrome Partitioning: Backtracking All Valid Splits

medium

How to solve LeetCode 131 Palindrome Partitioning using backtracking. Try every prefix, check if it is a palindrome, and recurse on the remainder.

6 min
stringsbacktracking

Palindrome Partitioning II: Minimum Cuts with DP

hard

How to solve LeetCode 132 in O(n^2) time and space. Two-phase DP: precompute a palindrome table, then find the minimum number of cuts so every partition is a palindrome.

5 min
stringsdynamic-programming

N-Queens II: Counting Solutions with Backtracking

hard

How to solve LeetCode 52 N-Queens II by counting valid n-queens configurations using backtracking with column and diagonal constraint sets.

7 min
backtracking

Multiply Strings: Grade-School Multiplication

medium

How to solve LeetCode 43 Multiply Strings. Simulate grade-school long multiplication digit by digit, accumulate into a result array using positional indexing, and strip leading zeros.

7 min
stringsmath

Minimum Depth of Binary Tree: Finding the Nearest Leaf

easy

How to solve LeetCode 111 Minimum Depth of Binary Tree with BFS for early termination. Visual walkthrough of the one-child trap and why BFS beats DFS here.

6 min
trees

Length of Last Word: Scanning from the Right

easy

How to solve LeetCode 58 Length of Last Word. Scan backwards from the end, skip trailing spaces, then count non-space characters for an O(n) time O(1) space solution.

4 min
strings

Largest Rectangle in Histogram: Monotonic Stack

hard

How to solve LeetCode 84 Largest Rectangle in Histogram using a monotonic increasing stack of indices. Visual walkthrough, Python solution, and O(n) complexity analysis.

8 min
arraysstacks

Jump Game II: Minimum Jumps with Greedy BFS

medium

How to solve LeetCode 45 Jump Game II in O(n) time and O(1) space using a greedy BFS approach that tracks jump boundaries.

7 min
arraysgreedy

Interleaving String: 2D DP on Two Strings

medium

How to solve LeetCode 97 Interleaving String with 2D DP. Build a boolean table tracking whether s1[:i] and s2[:j] can form s3[:i+j], with visual walkthrough.

8 min
stringsdynamic-programming

Insert Interval: Merge on the Fly

medium

How to solve LeetCode 57 Insert Interval with a clean three-phase scan. Walk through the approach, Python solution, edge cases, and the building blocks you can reuse.

5 min
arrays

First Missing Positive: Cyclic Sort in O(n) Time

hard

How to solve LeetCode 41 First Missing Positive using the array itself as a hash map. Cyclic sort places each value at its correct index, then a linear scan finds the gap.

6 min
arrays

Distinct Subsequences: 2D DP for Subsequence Counting

hard

How to solve LeetCode 115 Distinct Subsequences with 2D DP. Match/skip recurrence for counting subsequences, explained visually.

7 min
stringsdynamic-programming

Count and Say: Run-Length Encoding Sequence

medium

How to solve LeetCode 38 Count and Say. Build each term by run-length encoding the previous one, iterating n-1 times from the base case.

5 min
strings

Convert Sorted List to BST: Finding the Middle with Slow/Fast Pointers

medium

How to convert a sorted linked list into a height-balanced binary search tree using slow/fast pointers and recursion. LeetCode 109 explained with visuals.

5 min
linked-liststrees

Convert Sorted Array to BST: Divide and Conquer

easy

How to solve LeetCode 108 Convert Sorted Array to Binary Search Tree using divide and conquer. Visual walkthrough of the middle-element recursion approach.

6 min
treesbinary-search

Construct Binary Tree from Inorder and Postorder Traversal

medium

How to solve LeetCode 106: Construct Binary Tree from Inorder and Postorder Traversal. Use the last element of postorder as the root, split inorder to find left and right subtrees, and recurse.

7 min
trees

Combinations: Backtracking with a Size Constraint

medium

How to solve LeetCode 77 Combinations using backtracking with a start index and path length constraint. Recursion tree, pruning, and building blocks explained.

8 min
backtracking

Combination Sum II: Backtracking Without Duplicates

medium

How to solve LeetCode 40 Combination Sum II using sorted backtracking with same-level duplicate skipping. Visual walkthrough of pruning and deduplication.

8 min
arraysbacktracking

Candy: Two-Pass Greedy Distribution

hard

How to solve LeetCode 135 Candy with a two-pass greedy algorithm. Satisfy neighbor constraints from both directions and take the max.

8 min
arraysgreedy

Binary Tree Zigzag Level Order Traversal: BFS with Alternating Direction

medium

How to solve LeetCode 103 with BFS. Process each level of the tree with a queue, reversing every other level to produce the zigzag order.

5 min
trees

Binary Tree Maximum Path Sum: Global Max with Local Returns

hard

How to solve LeetCode 124 Binary Tree Maximum Path Sum. Post-order DFS returns the best single-branch contribution to the parent while updating a global max that considers both branches through each node.

8 min
trees

Binary Tree Level Order Traversal II: Bottom-Up BFS

medium

How to solve LeetCode 107 with BFS. Collect each level of the tree with a queue, then reverse the result to get bottom-up order from leaves to root.

5 min
trees

Binary Tree Inorder Traversal: Left, Root, Right

easy

How to solve LeetCode 94 Binary Tree Inorder Traversal with recursive and iterative stack-based approaches. Visual walkthrough of both solutions.

5 min
trees

Best Time to Buy and Sell Stock III: At Most Two Transactions

hard

How to solve LeetCode 123 in O(n) time and O(1) space using a four-state DP approach. Visual walkthrough of buy1, sell1, buy2, sell2.

5 min
arraysdynamic-programming

Best Time to Buy and Sell Stock II: Greedy Profit Collection

medium

How to solve LeetCode 122 Best Time to Buy and Sell Stock II with a greedy O(n) approach. Collect every upward price movement for maximum profit.

7 min
arraysgreedy

Balanced Binary Tree: Bottom-Up Height Check

easy

How to solve LeetCode 110 Balanced Binary Tree. A bottom-up DFS that computes height and detects imbalance in a single pass using -1 as a sentinel.

7 min
trees

Add Binary: Right-to-Left Addition with Carry

easy

How to solve LeetCode 67 Add Binary by walking two binary strings from right to left with carry propagation. A clean two-pointer pattern for string-based arithmetic.

5 min
stringsmath

Zigzag Conversion: Reading a Pattern Row by Row

medium

How to solve LeetCode 6 Zigzag Conversion. Simulate the zigzag placement row by row using a direction flag, then concatenate the rows.

5 min
strings

Swap Nodes in Pairs: Pairwise Linked List Manipulation

medium

How to solve LeetCode 24 Swap Nodes in Pairs with iterative and recursive approaches. Visual walkthrough of the dummy head and pointer rewiring technique.

6 min
linked-lists

Substring with Concatenation of All Words

hard

How to solve LeetCode 30 using a sliding window of fixed-length chunks and frequency map comparison. O(n * word_len) solution with step-by-step visual walkthrough.

7 min
stringshash-map

Search Insert Position: Binary Search for the Insertion Point

easy

How to solve LeetCode 35 Search Insert Position using binary search. When the target is missing, the left pointer lands on the exact insertion index.

5 min
arraysbinary-search

Roman to Integer: Left-to-Right with Subtraction Rule

easy

How to solve LeetCode 13 Roman to Integer. Scan left to right, compare each value to the next, and subtract when a smaller numeral precedes a larger one.

4 min
stringsmath

Reverse Nodes in k-Group: Chunked Linked List Reversal

hard

How to solve LeetCode 25 Reverse Nodes in k-Group. Visual walkthrough of counting k nodes, reversing each chunk in place, and connecting groups with O(n) time and O(1) space.

5 min
linked-lists

Reverse Integer: Digit Extraction with Overflow Check

medium

How to solve LeetCode 7 Reverse Integer. Extract digits with mod 10, build the reversed number, and check for 32-bit overflow before each step.

5 min
math

Remove Element: In-Place Array Filtering

easy

How to solve LeetCode 27 Remove Element using a read-write pointer to filter an array in-place. Visual walkthrough, Python solution, and building blocks.

4 min
arraystwo-pointers

Remove Duplicates from Sorted Array: In-Place with Two Pointers

easy

How to solve LeetCode 26 using a slow/fast two-pointer technique to remove duplicates in-place. Visual walkthrough, Python solution, and building blocks.

4 min
arraystwo-pointers

Regular Expression Matching: DP with Wildcards

hard

How to solve LeetCode 10 Regular Expression Matching with 2D dynamic programming. Handle '.' and '*' wildcards with a boolean DP table.

8 min
stringsdynamic-programming

Palindrome Number: Half-Reversal Without String Conversion

easy

How to solve LeetCode 9 Palindrome Number. Reverse only half the digits to check for a palindrome in O(log n) time and O(1) space, no string conversion needed.

5 min
math

Next Permutation: The Three-Step Algorithm

medium

How to solve LeetCode 31 Next Permutation in O(n) time and O(1) space. Find the pivot, swap the successor, and reverse the suffix.

6 min
arrays

Merge Two Sorted Lists: The Fundamental Merge Operation

easy

How to solve LeetCode 21 Merge Two Sorted Lists using a dummy head and two pointers. O(n+m) time, O(1) space solution explained with visual walkthrough.

5 min
linked-lists

Longest Valid Parentheses: Stack-Based Substring Tracking

hard

How to solve LeetCode 32 Longest Valid Parentheses using a stack of indices. Visual walkthrough, Python code, and the building blocks you need to recall it.

7 min
stringsstacks

Longest Common Prefix: Column-by-Column Comparison

easy

How to solve LeetCode 14 Longest Common Prefix. Compare characters column by column across all strings until they diverge.

5 min
strings

Integer to Roman: Greedy Value Decomposition

medium

How to solve LeetCode 12 Integer to Roman using a greedy lookup table. Build the roman numeral by subtracting values from largest to smallest.

5 min
stringsmath

Find the Index of the First Occurrence in a String

easy

How to solve LeetCode 28 Find the Index of the First Occurrence in a String. Slide a window of needle length over the haystack and compare substrings at each position.

4 min
strings

Find First and Last Position: Two Binary Searches

medium

How to solve LeetCode 34 Find First and Last Position of Element in Sorted Array in O(log n). Run binary search twice: once biased left, once biased right.

7 min
arraysbinary-search

Divide Two Integers: Bit Shifting Without Multiplication

medium

How to solve LeetCode 29 Divide Two Integers. Use bit shifts to double the divisor and subtract exponentially larger chunks, avoiding multiplication, division, and mod entirely.

6 min
mathbit-manipulation

Design Memory Allocator: Contiguous Block Allocation

medium

How to solve LeetCode 2502. Design a memory allocator that finds the leftmost consecutive free block and supports freeing by ID.

5 min
design

4Sum: Extending Two Pointers to Four Elements

medium

How to solve LeetCode 4Sum (problem 18) in O(n^3) time by sorting, fixing two elements with nested loops, and running a two-pointer scan for the remaining pair. Includes duplicate handling at every level.

6 min
arraystwo-pointers

3Sum Closest: Two Pointers with Distance Tracking

medium

How to solve LeetCode 16 3Sum Closest using sorting and two pointers with distance tracking. O(n^2) time, O(1) space.

5 min
arraystwo-pointers

White Box Testing: Testing with Knowledge of the Code

White box testing uses knowledge of internal code structure to design tests. Statement coverage, branch coverage, path coverage, and how to use them effectively.

9 min
software-engineeringpatterns

Verification vs. Validation: Are We Building It Right, or Building the Right Thing?

Verification checks if you built the software correctly. Validation checks if you built the correct software. Both are essential, and confusing them is one of the most common mistakes in software engineering.

8 min
software-engineeringpatterns

Unit Testing: Testing Individual Pieces in Isolation

What unit testing is, why it matters, how to write good unit tests, and common mistakes. The foundation of every testing strategy.

10 min
software-engineeringpatterns

Software Testing Types: Unit, Integration, White Box, Black Box, and More

A practical guide to the main types of software testing. Unit testing, integration testing, incremental testing, back-to-back testing, white box testing, and black box testing explained with examples.

11 min
software-engineeringpatterns

The Pipes and Filters Pattern in Software Architecture

The pipes and filters pattern processes data through a sequence of independent transformations. How it works, when to use it, and real-world examples from Unix to data pipelines.

10 min
software-engineeringpatterns

The Master-Worker Pattern in Software Architecture

The master-worker pattern divides work between a coordinator and multiple workers. How it powers divide-and-conquer, tree recursion, and distributed systems.

8 min
software-engineeringpatterns

The Layered Architecture Pattern in Software Design

The layered architecture pattern organizes systems into horizontal layers where each layer only communicates with the one directly above or below it. How it works and why it dominates enterprise software.

9 min
software-engineeringpatterns

Integration Testing: Verifying That Modules Work Together

Unit tests pass but the system is broken? Integration testing catches the bugs that live in the connections between modules.

9 min
software-engineeringpatterns

Incremental Testing: Adding One Module at a Time

Incremental testing integrates modules one at a time instead of all at once. Top-down, bottom-up, and sandwich approaches explained with examples.

12 min
software-engineeringpatterns

Deployment and Rollback: Shipping Software Safely

Deploying code to production is where plans meet reality. How deployment strategies, rollback procedures, and release practices keep your software running when things go wrong.

8 min
software-engineeringpatterns

Cohesion in Software Design: From Worst to Best

Cohesion measures how well the parts of a module belong together. High cohesion means focused, maintainable code. Low cohesion means a module doing too many unrelated things.

9 min
software-engineeringpatterns

The Client-Server Pattern in Software Architecture

The client-server pattern separates systems into requesters and providers. How it works, why it dominates modern software, and how it shows up in coding problems.

9 min
software-engineeringpatterns

Black Box Testing: Testing Without Seeing the Code

Black box testing designs tests from the specification, not the source code. Equivalence partitioning, boundary value analysis, and decision tables explained with examples.

10 min
software-engineeringpatterns

Back-to-Back Testing: Comparing Two Implementations

Back-to-back testing runs the same inputs through two implementations and compares outputs. Essential for rewrites, refactoring, and verifying optimized algorithms.

7 min
software-engineeringpatterns

Number of Adjacent Elements With the Same Color

medium

How to solve LeetCode 2672 efficiently. Maintain a running count of adjacent matching pairs instead of rescanning the array after every query.

5 min
arrays

Word Search II: Trie-Powered Board Search

hard

How to solve LeetCode 212 with a trie and backtracking DFS. Search for multiple words on a board in one pass instead of one search per word.

8 min
trie

Word Ladder: Shortest Transformation with BFS

hard

How to solve LeetCode 127 Word Ladder. Model words as graph nodes and use BFS to find the shortest transformation sequence.

6 min
graph

Rotate Image: In-Place Matrix Rotation

medium

How to rotate an n x n matrix 90 degrees clockwise in place. The transpose-then-reverse trick explained step by step.

6 min
arrays

10 Programming Principles That Make You Better at Coding Interviews

KISS, DRY, YAGNI, and 7 other programming principles are not just for production code. They directly improve how you solve coding interview problems.

5 min
software-engineeringpatterns

Number of 1 Bits: Counting Set Bits

easy

How to solve LeetCode 191 Number of 1 Bits. Two approaches: bit shifting and the n & (n-1) trick that clears one bit per step.

5 min
bit-manipulation

Maximal Square: DP on a Binary Matrix

medium

How to solve LeetCode 221 Maximal Square with dynamic programming. Build a DP table where each cell tracks the largest square ending at that corner.

6 min
dynamic-programming

Binary Tree Level Order Traversal: BFS with a Queue

medium

How to solve LeetCode 102 with BFS. Use a queue to process each level of the tree and collect results layer by layer.

5 min
trees

Implementation in Software Engineering and Coding Interviews

Technical debt, coding principles, and buy vs. build are not just project management concepts. They directly affect how you write code in interviews.

8 min
software-engineeringpatterns

Happy Number: Cycle Detection with a Hash Set

easy

How to solve LeetCode 202 Happy Number. Use a hash set to detect cycles in digit-square sequences, or use Floyd's cycle detection for O(1) space.

5 min
math

Generate Parentheses: Backtracking with Constraints

medium

How to solve LeetCode 22 Generate Parentheses. Use backtracking with open/close counters to build only valid combinations.

7 min
backtracking

Gas Station: Greedy Circuit Traversal

medium

How to solve LeetCode 134 Gas Station with a greedy one-pass algorithm. Find the unique starting point to complete a circular route.

8 min
greedy

Data Hiding vs. Encapsulation: What's the Difference?

Data hiding and encapsulation are related but distinct OOP concepts. Data hiding protects data from unauthorized access. Encapsulation wraps data and methods into a single unit to manage complexity.

6 min
software-engineeringpatterns

Coupling in Software Design: From Tight to Loose

Coupling measures how dependent modules are on each other. Tight coupling creates fragile, hard-to-maintain code. Loose coupling makes systems flexible and resilient. Here is the full spectrum.

8 min
software-engineeringpatterns

Copy List with Random Pointer: Deep Copy with a Hash Map

medium

How to solve LeetCode 138. Use a hash map to clone a linked list with random pointers in two passes.

6 min
linked-lists

Build vs. Buy: When to Write Code and When to Use What Already Exists

The build vs. buy decision is one of the most important in software engineering. How to evaluate cost, fit, and risk when choosing between custom code and existing solutions.

6 min
software-engineeringpatterns

The WRSPM Model: Why Constraints Shape Your Code

How the WRSPM model from software engineering applies to solving coding problems. World assumptions, specifications, and hidden variables matter more than you think.

8 min
software-engineeringpatterns

Word Break: Dynamic Programming on Strings

medium

How to solve LeetCode Word Break with DP. Check if a string can be segmented into dictionary words.

7 min
dynamic-programming

Unique Paths: 2D Grid Dynamic Programming

medium

How to solve LeetCode Unique Paths with 2D DP. The essential grid traversal pattern for interviews.

8 min
dynamic-programming

Task Scheduler: Greedy Frequency Counting

medium

How to solve LeetCode Task Scheduler with the greedy frame approach. Calculate minimum intervals from the most frequent task.

8 min
greedy

Symmetric Tree: Mirror Recursion

easy

How to solve LeetCode Symmetric Tree by comparing mirror pairs recursively. Visual walkthrough of the symmetry check.

6 min
trees

Surrounded Regions: Border DFS Trick

medium

How to solve LeetCode Surrounded Regions by protecting border-connected cells with reverse DFS. Think from the edges inward.

10 min
graphs

Subtree of Another Tree: Recursive Tree Matching

easy

How to solve LeetCode Subtree of Another Tree with recursive comparison. Check every node as a potential root match.

6 min
trees

String to Integer (atoi): State Machine Parsing

medium

How to solve LeetCode String to Integer using a state machine. Handle whitespace, signs, overflow, and edge cases.

8 min
arrays

Sort Colors: The Dutch National Flag Algorithm

medium

How to solve LeetCode Sort Colors in one pass with three pointers. The classic partition problem explained visually.

7 min
two-pointer

Software Architecture Patterns in Coding Problems

How pipe-and-filter, client-server, master-slave, and layered architecture patterns show up in coding interviews and algorithm design.

8 min
software-engineeringpatterns

Set Matrix Zeroes: In-Place Matrix Marking

medium

How to solve LeetCode Set Matrix Zeroes in O(1) space by using the first row and column as markers.

9 min
arrays

How the SDLC Applies to Solving Coding Problems

The software development lifecycle is not just for building products. It is the exact process top engineers use to solve coding interview problems.

8 min
software-engineeringpatterns

Reorder List: Three Classic Patterns in One Problem

medium

How to solve LeetCode Reorder List by combining fast-slow, reverse, and merge. Three patterns working together.

7 min
linked-list

Ransom Note: Frequency Counting with Available Supply

easy

How to solve LeetCode Ransom Note by counting available characters. A clean frequency map problem.

7 min
hash-map

Path Sum: Root-to-Leaf Target Check

easy

How to solve LeetCode Path Sum with DFS recursion. Subtract each node value and check if you reach zero at a leaf.

7 min
trees

Partition Equal Subset Sum: 0/1 Knapsack in Disguise

medium

How to solve LeetCode Partition Equal Subset Sum with DP. Recognize the 0/1 knapsack pattern hiding in a partition problem.

7 min
dynamic-programming

Palindrome Linked List: Fast-Slow + Reverse

easy

How to solve LeetCode Palindrome Linked List in O(1) space. Find middle, reverse second half, compare.

6 min
linked-list

Pacific Atlantic Water Flow: Reverse DFS from Edges

medium

How to solve LeetCode Pacific Atlantic Water Flow using reverse DFS from ocean borders. Think backwards to find the answer.

9 min
graphs

N-Queens: Constraint Backtracking

hard

How to solve LeetCode N-Queens using backtracking with column and diagonal constraints. The classic constraint satisfaction problem.

11 min
backtracking

Minimum Path Sum: Grid DP from Top-Left to Bottom-Right

medium

How to solve LeetCode Minimum Path Sum with 2D DP. Fill the grid cell by cell taking the minimum from above or left.

8 min
dynamic-programming

Merge K Sorted Lists: Min Heap Merge

hard

How to solve LeetCode Merge K Sorted Lists using a min heap. Efficiently pick the smallest element across k lists.

8 min
heap

Meeting Rooms II: Min Heap Scheduling

medium

How to solve LeetCode Meeting Rooms II with a min heap. Track the earliest ending meeting to reuse rooms.

7 min
heap

Maximum Subarray: Kadane's Algorithm

medium

How to solve LeetCode Maximum Subarray in O(n) with Kadane's algorithm. The key decision: extend or restart.

7 min
dynamic-programming

Maximum Product Subarray: Track Min and Max

medium

How to solve LeetCode Maximum Product Subarray. Why you need to track both minimum and maximum because negatives flip signs.

7 min
dynamic-programming

Maximal Rectangle: Histogram Stack on Every Row

hard

How to solve LeetCode Maximal Rectangle by building histograms row by row and applying the largest rectangle in histogram technique.

9 min
stacks

Longest Repeating Character Replacement: Sliding Window

medium

How to solve LeetCode Longest Repeating Character Replacement with sliding window. The window_size - max_freq trick.

7 min
sliding-window

Longest Palindrome: Greedy Character Pairing

easy

How to solve LeetCode Longest Palindrome (409) by counting character pairs. A greedy frequency problem.

6 min
hash-map

Longest Common Subsequence: 2D String DP

medium

How to solve LeetCode Longest Common Subsequence with a 2D DP table. The fundamental two-string comparison pattern.

7 min
dynamic-programming

Linked List Cycle II: Find the Cycle Start

medium

How to solve LeetCode Linked List Cycle II. Find where the cycle begins using Floyd's algorithm phase two.

6 min
linked-list

Koko Eating Bananas: Binary Search on the Answer

medium

How to solve LeetCode Koko Eating Bananas by binary searching the eating speed. The classic search-on-answer pattern.

7 min
binary-search

Implement Trie: The Prefix Tree

medium

How to build a Trie from scratch for LeetCode. Insert, search, and startsWith in O(m) time.

10 min
design

Implement Queue Using Stacks: The Lazy Transfer Trick

easy

How to solve LeetCode Implement Queue Using Stacks with amortized O(1) operations. Two stacks make a queue.

7 min
design

Flatten Binary Tree to Linked List: In-Place Preorder

medium

How to solve LeetCode Flatten Binary Tree to Linked List in O(1) space. Rewire the tree in preorder without extra storage.

7 min
trees

Find Peak Element: Binary Search on Slope

medium

How to solve LeetCode Find Peak Element in O(log n). Use binary search by following the ascending slope.

7 min
binary-search

Find Minimum in Rotated Sorted Array

medium

How to solve LeetCode Find Minimum in Rotated Sorted Array in O(log n). Binary search on the inflection point.

7 min
binary-search

Evaluate Reverse Polish Notation: Stack Calculator

medium

How to solve LeetCode Evaluate Reverse Polish Notation with a stack. Push numbers, pop for operators.

7 min
stacks

Edit Distance: The Classic 2D String DP

medium

How to solve LeetCode Edit Distance with 2D DP. Insert, delete, and replace operations explained visually.

8 min
dynamic-programming

Diameter of Binary Tree: Global Max with Local Returns

easy

How to solve LeetCode Diameter of Binary Tree. The key trick: return depth to parent, update diameter globally.

7 min
trees

Design Add and Search Words: Trie with Wildcards

medium

How to solve LeetCode Add and Search Words with a trie and DFS for wildcard dots. Extend the basic trie with backtracking.

9 min
design

Trees: Binary Trees, BSTs, and Traversals

Understanding binary trees and BSTs. Traversal orders, recursion patterns, and the essential tree interview problems.

9 min
data-structurestrees

Stacks: Last In, First Out

Understanding stacks from push/pop operations to real-world uses. Plus every stack interview problem you need to know.

7 min
data-structuresstacks

Stacks and Queues: LIFO vs FIFO

Understanding stacks and queues. How they differ, when to use each, and the key interview problems for both.

7 min
data-structuresstacks

Queues: First In, First Out

Understanding queues from enqueue/dequeue to BFS. How FIFO ordering powers level-by-level processing and graph traversal.

8 min
data-structuresqueues

Linked Lists: Pointers, Nodes, and Traversal

Understanding singly and doubly linked lists. How they work, when to use them, and the essential linked list problems.

8 min
data-structureslinked-list

Hash Maps: O(1) Lookup Power

Understanding hash maps from hash functions to collision handling. Plus every hash map interview problem you need to know.

8 min
data-structureshash-map

Arrays: The Foundation of Everything

Understanding arrays from memory layout to time complexities. Plus the essential array problems every developer should know.

5 min
data-structuresarrays

Construct Binary Tree from Preorder and Inorder

medium

How to solve LeetCode Construct Binary Tree from Preorder and Inorder Traversal. Split arrays recursively to rebuild the tree.

7 min
trees

Clone Graph: DFS with a Hash Map

medium

How to solve LeetCode Clone Graph using DFS and a hash map to track visited/cloned nodes. Deep copy a graph in O(n).

9 min
graphs

Alien Dictionary: Topological Sort on Characters

hard

How to solve LeetCode Alien Dictionary by extracting ordering from word pairs and running topological sort.

10 min
graphs

Add Two Numbers: Linked List Digit Addition

medium

How to solve LeetCode Add Two Numbers by traversing two linked lists with carry. The fundamental linked list builder pattern.

6 min
linked-list

XOR Cancellation: How Pairs Disappear Like Magic

easy

Understanding XOR from the ground up. How the cancellation property solves Single Number in O(n) time and O(1) space.

9 min
patterns

Search in Rotated Sorted Array: Modified Binary Search

medium

How to solve LeetCode Search in Rotated Sorted Array in O(log n). Identify the sorted half and search smartly.

8 min
binary-search

Remove Nth Node From End: Two Pointer Gap Technique

medium

How to solve LeetCode Remove Nth Node From End in one pass using the two-pointer gap technique.

6 min
linked-list

Longest Increasing Subsequence: DP and Binary Search

medium

How to solve LeetCode LIS in O(n^2) with DP or O(n log n) with patience sorting. Both approaches explained.

8 min
dynamic-programming

Letter Combinations of a Phone Number: Backtracking

medium

How to solve LeetCode Letter Combinations using backtracking. Build all combinations from digit-to-letter mapping.

9 min
backtracking

Combination Sum: Backtracking with Reuse

medium

How to solve LeetCode Combination Sum using backtracking with unlimited element reuse. Pruning explained visually.

10 min
backtracking

Word Search: Grid Backtracking

medium

How to solve LeetCode Word Search using DFS backtracking on a grid. The choose-explore-unchoose pattern.

10 min
backtracking

Validate BST: Range Checking vs Inorder

medium

How to solve LeetCode Validate BST with range bounds or inorder traversal. Two approaches compared.

7 min
trees

Valid Palindrome: Two Pointer String Check

easy

How to solve LeetCode Valid Palindrome with two pointers. Handle non-alphanumeric characters cleanly.

6 min
two-pointer

Top K Frequent Elements: Bucket Sort Trick

medium

How to solve LeetCode Top K Frequent Elements in O(n) with bucket sort. Faster than heap for this problem.

7 min
hash-map

Subsets: Backtracking Decision Tree

medium

How to solve LeetCode Subsets using backtracking. Generate all 2^n subsets with the include/exclude pattern.

9 min
backtracking

Spiral Matrix: Layer by Layer Traversal

medium

How to solve LeetCode Spiral Matrix with boundary tracking. The four-direction traversal pattern explained.

8 min
arrays

Serialize and Deserialize Binary Tree

hard

How to solve LeetCode Serialize/Deserialize Binary Tree with preorder DFS. Convert trees to strings and back.

8 min
trees

Permutations: Complete Backtracking Guide

medium

How to solve LeetCode Permutations using backtracking. Build all n! arrangements with the swap technique.

9 min
backtracking

Palindromic Substrings: Expand Around Center

medium

How to solve LeetCode Palindromic Substrings in O(n^2) using expand-from-center. Count all palindromes efficiently.

7 min
two-pointer

Min Stack: O(1) Minimum with Two Stacks

medium

How to implement LeetCode Min Stack with O(1) push, pop, and getMin. The auxiliary stack trick explained.

8 min
design

Merge Intervals: Sort and Sweep

medium

How to solve LeetCode Merge Intervals by sorting and merging overlapping ranges. The essential interval pattern.

7 min
arrays

Median of Two Sorted Arrays: Binary Search on Partitions

hard

How to solve LeetCode Median of Two Sorted Arrays in O(log(min(m,n))). The hardest binary search problem explained.

9 min
binary-search

LRU Cache: Hash Map + Doubly Linked List

medium

How to implement LeetCode LRU Cache with O(1) get and put. The classic design problem explained visually.

8 min
design

Lowest Common Ancestor: Post-Order Tree Logic

medium

How to solve LeetCode Lowest Common Ancestor using post-order DFS. The elegant recursive solution explained.

9 min
trees

Longest Palindromic Substring: Expand From Center

medium

How to solve LeetCode Longest Palindromic Substring in O(n^2). The expand-from-center technique explained visually.

7 min
two-pointer

Kth Largest Element: Heap vs Quickselect

medium

How to solve LeetCode Kth Largest Element with a min-heap or quickselect. Two O(n) approaches compared.

7 min
heap

House Robber: DP With a Twist

medium

How to solve LeetCode House Robber with dynamic programming. The rob-or-skip decision explained visually.

7 min
dynamic-programming

Decode Ways: DP String Decoding

medium

How to solve LeetCode Decode Ways with dynamic programming. Handle zeros and two-digit codes step by step.

9 min
dynamic-programming

Course Schedule: Cycle Detection with DFS

medium

How to solve LeetCode Course Schedule using topological sort and cycle detection. Graph DFS explained visually.

9 min
graphs

Coin Change: Classic Dynamic Programming

medium

How to solve LeetCode Coin Change with bottom-up DP. Visual table walkthrough for the unbounded knapsack pattern.

7 min
dynamic-programming

Valid Anagram: Frequency Counting Pattern

easy

How to solve LeetCode Valid Anagram using character frequency counting. Sort vs hash map approaches compared.

7 min
hash-map

3Sum: Sorting Plus Two Pointers

medium

How to solve LeetCode 3Sum in O(n^2) using sort and converging pointers. Handle duplicates cleanly.

8 min
two-pointer

Rotate Array: The Triple Reverse Trick

medium

How to solve LeetCode Rotate Array in O(n) time and O(1) space using three reversals.

7 min
arrays

Reverse Linked List: The Pointer Swap Technique

easy

How to solve LeetCode Reverse Linked List iteratively and recursively. Visual step-by-step pointer reversal guide.

6 min
linked-list

Product of Array Except Self: Two-Pass Prefix/Suffix

medium

How to solve LeetCode Product of Array Except Self in O(n) without division. Prefix and suffix product walkthrough.

6 min
greedy

Number of Islands: Grid DFS Pattern

medium

How to solve LeetCode Number of Islands using DFS flood fill. The essential grid traversal pattern explained.

10 min
graphs

Minimum Window Substring: Advanced Sliding Window

hard

How to solve LeetCode Minimum Window Substring with sliding window and frequency counting. O(n) solution.

9 min
sliding-window

Merge Sorted Array: The Backwards Trick

easy

How to solve LeetCode Merge Sorted Array in-place by filling from the end. O(n) two-pointer solution explained.

6 min
two-pointer

Maximum Depth of Binary Tree: Recursion Made Simple

easy

How to solve LeetCode Maximum Depth of Binary Tree with DFS recursion. Visual tree traversal walkthrough.

7 min
trees

Majority Element: Boyer-Moore Voting Algorithm

easy

How to solve LeetCode Majority Element in O(n) time and O(1) space with the Boyer-Moore voting algorithm.

7 min
arrays

Longest Substring Without Repeating Characters

medium

How to solve LeetCode Longest Substring Without Repeating Characters using sliding window and a set. O(n) solution.

7 min
sliding-window

Longest Consecutive Sequence: The Set Trick

medium

How to solve LeetCode Longest Consecutive Sequence in O(n) using a set. Why sorting is not needed.

7 min
hash-map

Linked List Cycle: Floyd's Tortoise and Hare

easy

How to detect a cycle in a linked list using O(1) space. Floyd's algorithm explained with visuals.

6 min
linked-list

Jump Game: Greedy Reachability

medium

How to solve LeetCode Jump Game in O(n) using greedy farthest-reach tracking. No DP needed.

9 min
greedy

Invert Binary Tree: The Famous Three-Line Solution

easy

How to solve LeetCode Invert Binary Tree with recursion. The problem that started a meme.

7 min
trees

Group Anagrams: Hash Map Grouping Pattern

medium

How to solve LeetCode Group Anagrams in O(n*k) using sorted keys. Step-by-step visual walkthrough.

7 min
hash-map

Daily Temperatures: Monotonic Stack Explained

medium

How to solve LeetCode Daily Temperatures using a monotonic stack. Visual walkthrough of the next-greater-element pattern.

8 min
stacks

Container With Most Water: Two Pointer Greedy

medium

How to solve LeetCode Container With Most Water in O(n) using two pointers. Why moving the shorter side is optimal.

7 min
two-pointer

Climbing Stairs: Your First Dynamic Programming Problem

easy

How to solve LeetCode Climbing Stairs with DP in O(n) time and O(1) space. The perfect intro to dynamic programming.

7 min
dynamic-programming

Binary Search (LeetCode 704): The Foundation

easy

How to implement binary search correctly. Avoid off-by-one errors with this clear visual walkthrough.

8 min
binary-search

Valid Parentheses: Stack Pattern Explained

easy

How to solve LeetCode Valid Parentheses using a stack. Visual step-by-step walkthrough with Python code.

7 min
stacks

Two Sum: The Classic Interview Starter

easy

How to solve LeetCode Two Sum in O(n) using a hash map complement lookup. Step-by-step walkthrough with visuals.

6 min
hash-map

Trapping Rain Water: Two Pointer Approach

hard

How to solve LeetCode Trapping Rain Water in O(n) time and O(1) space using two pointers. Visual step-by-step guide.

6 min
two-pointer

Contains Duplicate: Three Solutions Compared

easy

How to solve LeetCode Contains Duplicate using a set, sorting, or brute force. O(n) optimal solution explained.

6 min
hash-map

Best Time to Buy and Sell Stock: One Pass Solution

easy

How to solve LeetCode Best Time to Buy and Sell Stock in O(n) by tracking the running minimum. Visual walkthrough.

7 min
greedy

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.

9 min
patternssearching

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.

7 min
patternsstacks

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.

8 min
patternshash-maps

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.

8 min
patternsarrays

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.

8 min
patternsarrays