Blog
Guides on algorithm patterns and step-by-step LeetCode problem breakdowns.
Successful Pairs of Spells and Potions: Binary Search on Sorted Array
mediumHow 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.
Removing Stars From a String: Stack Simulation
mediumHow to solve LeetCode 2390 Removing Stars From a String using a stack. O(n) time, O(n) space solution explained with visual walkthrough.
Maximum Twin Sum of a Linked List: Reverse and Compare
mediumHow 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.
Find the Difference of Two Arrays: Set Operations
easyHow to solve LeetCode 2215 Find the Difference of Two Arrays using set difference. O(n + m) time solution explained with visual walkthrough.
Delete the Middle Node of a Linked List: Fast and Slow Pointers
mediumHow 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.
Three Divisors: Spotting Squares of Primes
easyHow to solve LeetCode 1952 Three Divisors. A number has exactly three positive divisors only when it is the square of a prime.
The Number of Weak Characters in the Game: Sorting Trick
mediumHow to solve LeetCode 1996 The Number of Weak Characters. Sort by attack descending and defense ascending to find weak characters in one pass.
The Number of the Smallest Unoccupied Chair
mediumHow 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.
The Number of Good Subsets: Bitmask DP Over Primes
hardHow to solve LeetCode 1994 The Number of Good Subsets. Bitmask DP using prime factorization to count subsets with square-free products.
Sum of Digits of String After Convert: Letter-to-Number Simulation
easyHow to solve LeetCode 1945 Sum of Digits of String After Convert. Convert each character to its alphabet position, concatenate, then repeatedly sum digits.
Reverse Prefix of Word: Find and Flip
easyHow 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.
Remove Stones to Minimize the Total
mediumHow to solve LeetCode 1962 using a max-heap to greedily halve the largest pile. Visual heap walkthrough with step-by-step operations.
Operations on Tree: Lock, Unlock, and Upgrade
mediumHow to solve LeetCode 1993 Operations on Tree. Design a locking tree with parent traversal and DFS for upgrade operations.
Number of Ways to Separate Numbers: DP with LCP Optimization
hardHow to solve LeetCode 1977 Number of Ways to Separate Numbers using dynamic programming with longest common prefix optimization.
Number of Ways to Arrive at Destination: Dijkstra with Path Counting
mediumHow to solve LeetCode 1976 Number of Ways to Arrive at Destination using modified Dijkstra's algorithm with path counting.
Number of Visible People in a Queue: Monotonic Stack
hardHow 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.
Number of Unique Good Subsequences: DP Without Leading Zeros
hardHow to solve LeetCode 1987 Number of Unique Good Subsequences with dynamic programming. Track subsequences ending in 0 and 1 separately to avoid leading zeros.
Number of Strings That Appear as Substrings in Word
easyHow to solve LeetCode 1967 by checking each pattern against the target word. Visual walkthrough of the substring matching approach.
Minimum Total Space Wasted With K Resizing Operations
mediumHow to solve LeetCode 1959 using interval DP. Visual walkthrough of partitioning an array to minimize wasted space with limited resizes.
Minimum Time to Type Word Using Special Typewriter: Greedy Circular Distance
easyHow to solve LeetCode 1974 Minimum Time to Type Word Using Special Typewriter. Greedy approach with circular distance calculation.
Minimum Number of Work Sessions to Finish the Tasks
mediumHow to solve LeetCode 1986 with bitmask DP. Track completed tasks as a bitmask and greedily pack them into sessions.
Minimum Number of Swaps to Make the String Balanced
mediumHow to solve LeetCode 1963 with a greedy bracket-counting approach. Visual walkthrough of tracking unmatched brackets and computing minimum swaps.
Minimum Non-Zero Product of the Array Elements
mediumHow to solve LeetCode 1969 using greedy bit manipulation and modular exponentiation. Visual walkthrough of minimizing the product of array elements.
Minimum Garden Perimeter to Collect Enough Apples: Binary Search on Math
mediumHow to solve LeetCode 1954 Minimum Garden Perimeter to Collect Enough Apples using binary search on a closed-form formula.
Minimum Difference Between Highest and Lowest of K Scores
easyHow 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.
Minimize the Difference Between Target and Chosen Elements
mediumHow to solve LeetCode 1981. Use row-by-row DP to track all achievable sums, then find the one closest to the target.
Maximum Product of the Length of Two Palindromic Substrings
hardHow to solve LeetCode 1960 using Manacher's algorithm with prefix and suffix maximums. Visual breakdown of finding optimal non-overlapping palindromes.
Maximum Number of Weeks for Which You Can Work: Greedy Scheduling
mediumHow 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.
Maximum Matrix Sum: Greedy with Negative Count
mediumHow to solve LeetCode 1975 Maximum Matrix Sum. Greedy approach counting negatives and finding minimum absolute value.
Maximum Genetic Difference Query: Trie + DFS
hardHow to solve LeetCode 1938 Maximum Genetic Difference Query. Combine a bitwise trie with DFS traversal to answer XOR queries efficiently.
Maximum Compatibility Score Sum: Optimal Assignment with Backtracking
mediumHow to solve LeetCode 1947 Maximum Compatibility Score Sum using backtracking over permutations and bitmask DP.
Last Day Where You Can Still Cross
hardHow 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.
Largest Number After Mutating Substring: Greedy Digit Replacement
mediumHow to solve LeetCode 1946 Largest Number After Mutating Substring with a greedy scan. Replace a contiguous substring of digits to maximize the number.
GCD Sort of an Array: Union-Find with Prime Factorization
hardHow 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.
First Day Where You Have Been in All the Rooms: DP with Modular Arithmetic
mediumHow 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.
Find Unique Binary String: Cantor's Diagonal Trick
mediumHow 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.
Find the Middle Index in Array: Prefix Sum in One Pass
easyHow to solve LeetCode 1991 Find the Middle Index in Array using a running prefix sum. O(n) solution explained with visual walkthrough.
Find the Longest Valid Obstacle Course at Each Position
hardHow to solve LeetCode 1964 using patience sorting with binary search. Visual walkthrough of the longest non-decreasing subsequence approach.
Find the Kth Largest Integer in the Array
mediumHow to solve LeetCode 1985 Find the Kth Largest Integer in the Array. Custom string comparison for large numbers explained step by step.
Find if Path Exists in Graph: BFS, DFS, and Union-Find
easyHow to solve LeetCode 1971 Find if Path Exists in Graph using BFS, DFS, and Union-Find. Check graph connectivity in O(n + e).
Find Greatest Common Divisor of Array: Min, Max, and Euclid
easyHow 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.
Find Array Given Subset Sums: Divide and Reconstruct
hardHow 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.
Find All Groups of Farmland: Rectangle Scanning Pattern
mediumHow 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.
Describe the Painting: Sweep Line on Segments
mediumHow to solve LeetCode 1943 Describe the Painting. Use a sweep line with a difference array to merge overlapping color segments efficiently.
Delete Duplicate Folders in System: Trie Serialization and Hash-Based Dedup
hardHow to solve LeetCode 1948 Delete Duplicate Folders in System using trie construction, subtree serialization, and hash map deduplication.
Delete Characters to Make Fancy String: Greedy Filtering
easyHow to solve LeetCode 1957 Delete Characters to Make Fancy String by greedily filtering out characters that would create three consecutive duplicates.
Count Special Quadruplets: From Brute Force to Hash Map
easyHow to solve LeetCode 1995 Count Special Quadruplets. Reduce O(n^4) brute force to O(n^2) with a hash map trick.
Count Number of Special Subsequences: Phase-Based DP
hardHow to solve LeetCode 1955 Count Number of Special Subsequences using a three-state DP that tracks subsequence phases.
Check If String Is a Prefix of Array
easyHow to solve LeetCode 1961 by incrementally concatenating array elements. A clean string matching exercise with early termination.
Check if Move is Legal: Directional Grid Search
mediumHow to solve LeetCode 1958 Check if Move is Legal by searching all 8 directions for a valid Othello line on the board.
Check if All Characters Have Equal Number of Occurrences
easyHow 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.
Array With Elements Not Equal to Average of Neighbors
mediumHow to solve LeetCode 1968 using a sorting-based wiggle arrangement. Visual walkthrough of the greedy interleaving approach.
Unique Length-3 Palindromic Subsequences: First and Last Occurrence
mediumHow to solve LeetCode 1930 Unique Length-3 Palindromic Subsequences by finding first and last occurrences and counting distinct middle characters.
The Number of Full Rounds You Have Played: Time Interval Math
mediumHow to solve LeetCode 1904 The Number of Full Rounds You Have Played. Step-by-step walkthrough with visuals.
Earliest and Latest Rounds Where Players Compete: Tournament Simulation
hardHow to solve LeetCode 1900 The Earliest and Latest Rounds Where Players Compete. Step-by-step walkthrough with visuals.
Sum of Floored Pairs
hardHow to solve LeetCode 1862 using prefix sums and harmonic series counting. An efficient approach that avoids brute-force pair enumeration.
Sum of All Subset XOR Totals
easyHow to solve LeetCode 1863 using a bit-contribution insight that reduces subset enumeration to a single OR and a left shift.
Sum Game: Game Theory with Greedy Analysis
mediumHow to solve LeetCode 1927 Sum Game with game theory. Visual walkthrough of optimal play between Alice and Bob.
Substrings of Size Three with Distinct Characters
easyHow to solve LeetCode 1876 by sliding a fixed-size window and checking for distinct characters. A clean intro to sliding windows.
Stone Game VIII: Prefix Sums Meet Game Theory
hardHow to solve LeetCode 1872 Stone Game VIII by reducing the game to a prefix sum DP. The elegant simplification behind a hard problem.
Sorting the Sentence
easyHow to solve LeetCode 1859 by extracting position numbers from shuffled words. A clean string manipulation exercise.
Rotating the Box
mediumHow to solve LeetCode 1861 by simulating gravity and rotating a matrix. A two-step approach combining physics simulation with matrix rotation.
Remove One Element to Make the Array Strictly Increasing
easyHow to solve LeetCode 1909 by finding violation points and testing one removal. A clean single-pass approach with visual walkthrough.
Remove All Occurrences of a Substring: Stack-Based String Processing
mediumHow 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.
Reduction Operations to Make the Array Elements Equal
mediumHow to solve LeetCode 1887 Reduction Operations to Make the Array Elements Equal by sorting and counting distinct value levels.
Redistribute Characters to Make All Strings Equal: Frequency Divisibility Check
easyHow to solve LeetCode 1897 Redistribute Characters to Make All Strings Equal. Step-by-step walkthrough with visuals.
Process Tasks Using Servers
mediumHow to solve LeetCode 1882 Process Tasks Using Servers. Use two heaps to efficiently track free and busy servers, assigning tasks by weight priority.
Painting a Grid With Three Different Colors: Column-State DP
hardHow to solve LeetCode 1931 Painting a Grid With Three Different Colors using column-state dynamic programming to count valid colorings.
Number of Wonderful Substrings: Bitmask Parity Tracking
mediumHow to solve LeetCode 1915 Number of Wonderful Substrings using bitmask XOR parity and prefix counting. Visual walkthrough with Python solution.
Number of Ways to Rearrange Sticks With K Sticks Visible
hardHow to solve LeetCode 1866 using dynamic programming and the connection to unsigned Stirling numbers of the first kind.
Nearest Exit from Entrance in Maze: BFS Shortest Path
mediumHow to solve LeetCode 1926 Nearest Exit from Entrance in Maze using BFS. Visual grid walkthrough for the shortest path in a matrix.
Minimum XOR Sum of Two Arrays
hardHow 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.
Minimum Speed to Arrive on Time: Binary Search on the Answer
mediumHow to solve LeetCode 1870 Minimum Speed to Arrive on Time using binary search on the answer space. Search speeds, not arrays.
Minimum Space Wasted From Packaging: Binary Search with Prefix Sums
hardHow to solve LeetCode 1889 Minimum Space Wasted From Packaging using sorted arrays, binary search, and prefix sums to minimize total waste.
Minimum Skips to Arrive at Meeting On Time: DP on Skips
hardHow to solve LeetCode 1883 Minimum Skips to Arrive at Meeting On Time with dynamic programming. Track minimum travel time for each skip count.
Minimum Number of Swaps to Make the Binary String Alternating
mediumHow to solve LeetCode 1864 Minimum Number of Swaps to Make the Binary String Alternating using a greedy counting approach with two target patterns.
Minimum Number of Flips to Make the Binary String Alternating
mediumHow 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.
Minimum Cost to Reach Destination in Time: DP on Graphs
hardHow to solve LeetCode 1928 Minimum Cost to Reach Destination in Time using dynamic programming with a time constraint on a weighted graph.
Minimum Cost to Change the Final Value of Expression: Stack DP on Boolean Expressions
hardHow to solve LeetCode 1896 Minimum Cost to Change the Final Value of Expression. Step-by-step walkthrough with visuals.
Minimum Absolute Difference Queries: Prefix Counts on Small Domains
mediumHow to solve LeetCode 1906 using prefix frequency arrays. Visual walkthrough of answering range queries with O(1) value lookups.
Minimize Maximum Pair Sum in Array: Sort and Pair
mediumHow to solve LeetCode 1877 Minimize Maximum Pair Sum by sorting and pairing extremes. A greedy two-pointer approach.
Merge Triplets to Form Target Triplet: Greedy Filtering
mediumHow to solve LeetCode 1899 Merge Triplets to Form Target Triplet. Step-by-step walkthrough with visuals.
Merge BSTs to Create Single BST: Grafting Trees Together
hardHow to solve LeetCode 1932 Merge BSTs to Create Single BST by matching leaf nodes to roots and validating the merged BST.
Maximum Value after Insertion
mediumHow 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.
Maximum Product Difference Between Two Pairs
easyHow to solve LeetCode 1913 Maximum Product Difference Between Two Pairs. One-pass solution with visuals and complexity analysis.
Maximum Number of Words You Can Type: Set Lookup
easyHow to solve LeetCode 1935 Maximum Number of Words You Can Type using a set of broken letters and simple word filtering.
Maximum Number of Removable Characters: Binary Search on the Answer
mediumHow to solve LeetCode 1898 Maximum Number of Removable Characters. Step-by-step walkthrough with visuals.
Maximum Number of Points with Cost: Left-Right DP Sweep
mediumHow 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).
Maximum Alternating Subsequence Sum: Two-State DP
mediumHow to solve LeetCode 1911 with a two-variable DP tracking even and odd positions. Visual walkthrough of the state transition pattern.
Longest Common Subpath: Binary Search with Rolling Hash
hardHow 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.
Longer Contiguous Segments of Ones than Zeros
easyHow to solve LeetCode 1869 Longer Contiguous Segments of Ones than Zeros with a single pass, tracking run lengths for both digits.
Largest Odd Number in String: Right-to-Left Scan
easyHow to solve LeetCode 1903 Largest Odd Number in String. Step-by-step walkthrough with visuals.
Largest Magic Square: Prefix Sums on a Matrix
mediumHow to solve LeetCode 1895 Largest Magic Square. Step-by-step walkthrough with visuals.
Largest Color Value in a Directed Graph
hardHow to solve LeetCode 1857 using topological sort and dynamic programming. Visual walkthrough of tracking color frequencies along directed paths.
Jump Game VII: BFS with a Sliding Window
mediumHow to solve LeetCode 1871 Jump Game VII efficiently using BFS with a pointer optimization. Avoid the TLE trap.
Incremental Memory Leak
mediumHow to solve LeetCode 1860 by simulating memory allocation second by second. A clean simulation problem with a mathematical shortcut.
Get Biggest Three Rhombus Sums in a Grid
mediumHow 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.
Finding Pairs With a Certain Sum
mediumHow to solve LeetCode 1865 Finding Pairs With a Certain Sum using a frequency map for efficient pair counting across two arrays.
Find the Student that Will Replace the Chalk: Prefix Sum Meets Binary Search
mediumHow to solve LeetCode 1894 by combining prefix sums, modulo arithmetic, and binary search. Step-by-step walkthrough with visuals.
Eliminate Maximum Number of Monsters: Greedy with Sorted Arrival Times
mediumHow to solve LeetCode 1921 Eliminate Maximum Number of Monsters using greedy sorting. Compute arrival times, sort, and fire at the closest monster each minute.
Determine Whether Matrix Can Be Obtained By Rotation
easyHow to solve LeetCode 1886 Determine Whether Matrix Can Be Obtained By Rotation by checking all four 90-degree rotations against the target.
Design Movie Rental System: Sorted Containers Meet Heaps
hardHow to solve LeetCode 1912 Design Movie Rental System using sorted sets and heaps. Step-by-step data structure walkthrough with visuals.
Cyclically Rotating a Grid: Layer-by-Layer Simulation
mediumHow to solve LeetCode 1914 Cyclically Rotating a Grid by extracting layers and rotating elements. Visual walkthrough with Python solution.
Count Ways to Build Rooms in an Ant Colony: Tree Combinatorics
hardHow 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.
Count Sub Islands: Grid DFS with Cross-Reference
mediumHow to solve LeetCode 1905 Count Sub Islands using DFS to validate islands across two grids. Visual walkthrough of the cross-reference pattern.
Count Square Sum Triples: Enumerating Pythagorean Triples
easyHow to solve LeetCode 1925 Count Square Sum Triples by iterating over all pairs and checking for perfect squares. Full walkthrough with visuals.
Count Good Numbers: Modular Exponentiation
mediumHow 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.
Concatenation of Array: Simple Array Construction
easyHow to solve LeetCode 1929 Concatenation of Array. Visual walkthrough of array duplication and index mapping.
Check if Word Equals Summation of Two Words
easyHow 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.
Check if All the Integers in a Range Are Covered: Boolean Array Marking
easyHow to solve LeetCode 1893 by marking covered integers in a boolean array. Step-by-step walkthrough with visuals.
Build Array from Permutation: Double Indexing in One Pass
easyHow 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.
Add Minimum Number of Rungs: Greedy Gap Filling
mediumHow to solve LeetCode 1936 Add Minimum Number of Rungs with a greedy single-pass approach that fills gaps exceeding the max climb distance.
Truncate Sentence: Split, Slice, and Join
easyHow to solve LeetCode 1816 Truncate Sentence. Split the sentence into words, take the first k, and join them back together.
Sum of Digits in Base K
easyHow to solve LeetCode 1837 Sum of Digits in Base K using repeated division. A clean math pattern for base conversion.
Sum of Beauty of All Substrings
mediumHow to solve LeetCode 1781 Sum of Beauty of All Substrings using frequency counting. Enumerate substrings and track character frequencies incrementally.
Splitting a String Into Descending Consecutive Values: Backtracking
mediumHow to solve LeetCode 1849 Splitting a String Into Descending Consecutive Values using backtracking. Try each split point and recursively validate the descending sequence.
Single-Threaded CPU
mediumHow to solve LeetCode 1834 Single-Threaded CPU using sorting and a min-heap. A simulation problem explained with visual walkthroughs.
Sign of the Product of an Array: Count Negatives
easyHow 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.
Sentence Similarity III: Two-Pointer Word Matching
mediumHow 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.
Second Largest Digit in a String: Single-Pass Tracking
easyHow to solve LeetCode 1796 Second Largest Digit in a String with a single pass. Clean Python solution with visual walkthrough.
Seat Reservation Manager: Min-Heap Design Pattern
mediumHow to solve LeetCode 1845 Seat Reservation Manager using a min-heap. The design pattern for always fetching the smallest available element.
Replace All Digits with Characters
easyHow to solve LeetCode 1844 Replace All Digits with Characters. Apply the shift operation to transform digit characters based on their preceding letter.
Queries on Number of Points Inside a Circle: Distance Check Pattern
mediumHow to solve LeetCode 1828 Queries on Number of Points Inside a Circle. Check each point against each query circle using squared distance.
Number of Restricted Paths From First to Last Node: Dijkstra + DP Pattern
mediumHow 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.
Number of Orders in the Backlog: Dual Heap Simulation
mediumHow to solve LeetCode 1801 with a max-heap for buys and a min-heap for sells. Simulate an order book by matching and accumulating.
Number of Different Subsequences GCDs: Enumerate Candidate GCDs
hardHow 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.
Number of Different Integers in a String: Parsing and Sets
easyHow to solve LeetCode 1805 Number of Different Integers in a String by extracting integers and counting unique values with a set.
Minimum Sideway Jumps: Lane-Switching DP Pattern
mediumHow to solve LeetCode 1824 Minimum Sideway Jumps using dynamic programming. Track minimum jumps across three lanes with a greedy DP approach.
Minimum Operations to Make the Array Increasing: Greedy Pass Pattern
easyHow to solve LeetCode 1827 Minimum Operations to Make the Array Increasing with a single greedy pass. Track the minimum required value as you scan.
Minimum Number of Operations to Reinitialize a Permutation
mediumHow 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.
Minimum Number of Operations to Make String Sorted
hardHow 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.
Minimum Interval to Include Each Query
hardHow 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.
Minimum Elements to Add to Form a Given Sum: Greedy Math Pattern
mediumHow 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.
Minimum Distance to the Target Element: Linear Scan
easyHow to solve LeetCode 1848 Minimum Distance to the Target Element with a single pass through the array. Track the closest matching index.
Minimum Adjacent Swaps to Reach the Kth Smallest Number
mediumHow to solve LeetCode 1850 Minimum Adjacent Swaps to Reach the Kth Smallest Number using next permutation and greedy swap counting.
Minimum Absolute Sum Difference: Binary Search for Best Replacement
mediumHow to solve LeetCode 1818 Minimum Absolute Sum Difference. Sort a copy of nums1, then binary search to find the best replacement for each position.
Maximum XOR for Each Query: Prefix XOR Pattern
mediumHow to solve LeetCode 1829 Maximum XOR for Each Query using prefix XOR and bit masking. Process queries in reverse with cumulative XOR.
Maximum Value at a Given Index in a Bounded Array: Binary Search on Answer
mediumHow 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.
Maximum Subarray Min-Product: Monotonic Stack + Prefix Sums
mediumHow to solve LeetCode 1856 Maximum Subarray Min-Product using a monotonic stack and prefix sums. Visual walkthrough, Python solution, and O(n) complexity analysis.
Maximum Score of a Good Subarray: Two-Pointer Expansion
hardHow to solve LeetCode 1793 Maximum Score of a Good Subarray using greedy two-pointer expansion from k. Visual walkthrough included.
Maximum Population Year
easyHow 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.
Maximum Number of Groups Getting Fresh Donuts: DP with Remainder States
hardHow 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.
Maximum Number of Consecutive Values You Can Make: Greedy Reachability
mediumHow 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.
Maximum Ice Cream Bars
mediumHow to solve LeetCode 1833 Maximum Ice Cream Bars using a greedy sorting approach. Buy the cheapest items first to maximize count.
Maximum Element After Decreasing and Rearranging: Sort and Greedy
mediumHow to solve LeetCode 1846 Maximum Element After Decreasing and Rearranging using sorting and greedy adjustment. Build the largest valid sequence step by step.
Maximum Distance Between a Pair of Values: Two Pointer Sweep
mediumHow 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.
Maximum Building Height
hardHow to solve LeetCode 1840 Maximum Building Height. Propagate height restrictions in both directions, then find the peak between consecutive restricted buildings.
Maximum Average Pass Ratio: Greedy Heap Pattern
mediumHow to solve LeetCode 1792 Maximum Average Pass Ratio using a max heap and greedy allocation. Visual walkthrough included.
Maximum Ascending Subarray Sum: Greedy Scan Pattern
easyHow 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.
Maximize Score After N Operations: Bitmask DP Pattern
hardHow to solve LeetCode 1799 Maximize Score After N Operations using bitmask dynamic programming. The bitmask DP pattern explained with visual walkthroughs.
Maximize Number of Nice Divisors: The Power of 3s
hardHow to solve LeetCode 1808 Maximize Number of Nice Divisors using the mathematical insight that splitting into 3s maximizes the product, with modular exponentiation.
Make the XOR of All Segments Equal to Zero: DP + Bit Manipulation Pattern
hardHow 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.
Longest Substring Of All Vowels in Order
mediumHow to solve LeetCode 1839 Longest Substring Of All Vowels in Order. Track groups of consecutive vowels and check for the beautiful substring pattern.
Frequency of the Most Frequent Element
mediumHow to solve LeetCode 1838 Frequency of the Most Frequent Element using sorting and sliding window. Track the cost to equalize a window of elements.
Finding the Users Active Minutes: Hash Map Counting
mediumHow 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.
Finding MK Average: Sorted Window Design Pattern
hardHow to solve LeetCode 1825 Finding MK Average using sorted containers and running sums. A data structure design problem with trimmed means.
Find XOR Sum of All Pairs Bitwise AND
hardHow to solve LeetCode 1835 Find XOR Sum of All Pairs Bitwise AND using bit manipulation properties. A math-heavy problem explained with visual walkthroughs.
Find the Winner of the Circular Game: The Josephus Problem
mediumHow 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.
Find Nearest Point That Has the Same X or Y Coordinate
easyHow to solve LeetCode 1779 Find Nearest Point using a simple linear scan. Filter valid points and track the minimum Manhattan distance.
Find Center of Star Graph: Graph Observation Pattern
easyHow to solve LeetCode 1791 Find Center of Star Graph. A simple graph observation that appears in interviews.
Evaluate the Bracket Pairs of a String: Hash Map Substitution
mediumHow to solve LeetCode 1807 Evaluate the Bracket Pairs of a String using hash map lookups for bracket pair replacement.
Determine Color of a Chessboard Square: Quick Math Trick
easyHow to solve LeetCode 1812 Determine Color of a Chessboard Square. Use coordinate parity to instantly determine if a square is black or white.
Design Authentication Manager: Hash Map Design Pattern
mediumHow to solve LeetCode 1797 Design Authentication Manager using a hash map for token management. Clean Python solution with visual walkthrough.
Count Pairs With XOR in a Range: Trie Bit Manipulation
hardHow to solve LeetCode 1803 Count Pairs With XOR in a Range using a bitwise trie. Count valid pairs efficiently with prefix counting.
Count Pairs Of Nodes: Sorted Degrees and Two Pointers
hardHow to solve LeetCode 1782 Count Pairs Of Nodes using sorted degrees, two pointers, and edge correction. Answer multiple queries efficiently.
Count Nice Pairs in an Array: Hash Map with Algebraic Trick
mediumHow 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.
Closest Room: Offline Queries with Sorted Set
hardHow to solve LeetCode 1847 Closest Room using offline query processing with sorting and binary search. The pattern for handling range-filtered nearest-neighbor queries.
Check if the Sentence Is Pangram
easyHow to solve LeetCode 1832 Check if the Sentence Is Pangram using a set. A simple string problem explained with visual walkthroughs.
Check if One String Swap Can Make Strings Equal: Mismatch Counting Pattern
easyHow to solve LeetCode 1790 Check if One String Swap Can Make Strings Equal using mismatch counting. The character comparison pattern explained with visual walkthroughs.
Check if Number is a Sum of Powers of Three
mediumHow 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.
Check if Binary String Has at Most One Segment of Ones: Simple Scan Pattern
easyHow 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.
Car Fleet II: Monotone Stack Collision Times
hardHow to solve LeetCode 1776 Car Fleet II using a monotone stack. Process cars from right to left to calculate collision times efficiently.
Where Will the Ball Fall: Grid Simulation
mediumHow to solve LeetCode 1706 Where Will the Ball Fall. Simulate each ball column by column through the grid of diagonal boards.
Ways to Split Array Into Three Subarrays: Prefix Sums + Binary Search
mediumHow 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.
Tuple with Same Product: Hash Map Counting Pattern
mediumHow to solve LeetCode 1726 Tuple with Same Product using hash map pair counting. The product-pair technique explained with visual walkthroughs.
Tree of Coprimes: DFS with Ancestor Tracking
hardHow to solve LeetCode 1766 Tree of Coprimes using DFS with value-indexed ancestor tracking. Find the closest coprime ancestor for each node efficiently.
Swapping Nodes in a Linked List: Two-Pointer Technique
mediumHow 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.
Sum of Unique Elements: Frequency Counting Pattern
easyHow to solve LeetCode 1748 Sum of Unique Elements using hash map frequency counting. Clean visual explanation.
Restore the Array From Adjacent Pairs
mediumHow to solve LeetCode 1743 by building an adjacency map and walking the chain. A clean graph traversal problem using hash maps in O(n).
Palindrome Partitioning IV: Three-Way Palindrome Split
hardHow to solve LeetCode 1745 Palindrome Partitioning IV using palindrome DP precomputation and two-pointer splits. Clean visual explanation.
Number of Ways to Reconstruct a Tree: Ancestor Pair Analysis
hardHow 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.
Number of Students Unable to Eat Lunch: Queue Simulation
easyHow to solve LeetCode 1700 using counting instead of simulation. Learn why counting preferences beats direct queue simulation.
Number of Rectangles That Can Form the Largest Square
easyHow to solve LeetCode 1725 Number of Rectangles That Can Form the Largest Square. A clean single-pass approach explained with visual walkthroughs.
Minimum Operations to Make a Subsequence: LIS Reduction
hardHow to solve LeetCode 1713 Minimum Operations to Make a Subsequence by reducing it to Longest Increasing Subsequence with binary search.
Minimum Number of People to Teach: Greedy Language Selection
mediumHow 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.
Minimum Operations to Move All Balls: Prefix Sum Pattern
mediumHow 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).
Minimum Limit of Balls in a Bag: Binary Search on Answer Pattern
mediumHow 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.
Minimum Length of String After Deleting Similar Ends: Two-Pointer Trim
mediumHow to solve LeetCode 1750 Minimum Length of String After Deleting Similar Ends using two pointers. Clean visual explanation.
Minimum Degree of a Connected Trio in a Graph: Triangle Detection Pattern
hardHow 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.
Minimum Changes To Make Alternating Binary String: Greedy Counting Pattern
easyHow to solve LeetCode 1758 Minimum Changes To Make Alternating Binary String using greedy counting. Compare against both alternating patterns and take the minimum.
Minimum Adjacent Swaps for K Consecutive Ones: Sliding Window on Positions
hardHow to solve LeetCode 1703 using position extraction, median grouping, and prefix sums. The sliding window meets meeting point pattern.
Minimize Hamming Distance After Swap Operations: Union-Find Grouping
mediumHow to solve LeetCode 1722 Minimize Hamming Distance After Swap Operations using Union-Find. Group connected indices and count mismatches per component.
Merge Strings Alternately: Two-Pointer Interleaving
easyHow to solve LeetCode 1768 Merge Strings Alternately using two pointers. A clean approach to interleaving characters from two strings.
Maximum XOR With an Element From Array: Offline Queries with a Trie
hardHow to solve LeetCode 1707 Maximum XOR With an Element From Array. Sort queries by limit, build a binary trie incrementally, and greedily maximize XOR.
Maximum Units on a Truck: Greedy Sorting
easyHow to solve LeetCode 1710 Maximum Units on a Truck. Sort boxes by units per box in descending order and greedily load the truck.
Maximum Score From Removing Substrings: Greedy Stack Pattern
mediumHow to solve LeetCode 1717 Maximum Score From Removing Substrings using a greedy two-pass stack approach. Visual walkthrough of the greedy ordering strategy.
Maximum Score From Removing Stones: Greedy Math
mediumHow to solve LeetCode 1753 Maximum Score From Removing Stones using a greedy math approach. The pile balancing pattern explained visually.
Maximum Score from Performing Multiplication Operations: DP on Two Ends
hardHow to solve LeetCode 1770 using dynamic programming on array endpoints. A clear explanation of the interval DP pattern with visual walkthrough.
Maximum Number of Events That Can Be Attended II: DP with Binary Search
hardHow 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.
Maximum Number of Balls in a Box
easyHow 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.
Maximum Binary String After Change: Greedy Pattern
mediumHow to solve LeetCode 1702 Maximum Binary String After Change with a greedy approach. Learn why all zeros can be collected and converted.
Maximum Absolute Sum of Any Subarray: Prefix Sum Extremes
mediumHow to solve LeetCode 1749 Maximum Absolute Sum of Any Subarray using prefix sum tracking. Clean visual explanation.
Maximize Palindrome Length From Subsequences
hardHow to solve LeetCode 1771 by extending longest palindromic subsequence to two strings. A visual guide to the DP approach.
Map of Highest Peak: Multi-Source BFS on a Grid
mediumHow 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.
Longest Nice Substring: Divide and Conquer Pattern
easyHow to solve LeetCode 1763 Longest Nice Substring using divide and conquer. Split at characters without both cases and recursively find the longest nice substring.
Latest Time by Replacing Hidden Digits: Greedy Position-by-Position
easyHow to solve LeetCode 1736 Latest Time by Replacing Hidden Digits using a greedy approach. Process each digit position independently for the maximum valid time.
Largest Submatrix With Rearrangements: Sorting Heights Pattern
mediumHow to solve LeetCode 1727 Largest Submatrix With Rearrangements using column height sorting. The histogram-meets-greedy approach explained with visual walkthroughs.
Largest Merge of Two Strings: Greedy Suffix Comparison
mediumHow to solve LeetCode 1754 Largest Merge of Two Strings using greedy suffix comparison. Building the lexicographically largest merge explained visually.
Form Array by Concatenating Subarrays: Greedy Matching Pattern
mediumHow to solve LeetCode 1764 Form Array by Concatenating Subarrays of Another Array using greedy matching. Visual walkthrough and clean Python solution.
Find the Highest Altitude: Prefix Sum Basics
easyHow to solve LeetCode 1732 Find the Highest Altitude using prefix sums. A clean introduction to running totals.
Find Minimum Time to Finish All Jobs: Backtracking with Pruning
hardHow to solve LeetCode 1723 Find Minimum Time to Finish All Jobs using backtracking with pruning. Job scheduling optimization explained with visual walkthroughs.
Find Kth Largest XOR Coordinate Value
mediumHow to solve LeetCode 1738 using 2D prefix XOR and a heap. Learn the inclusion-exclusion principle for XOR over rectangular regions.
Equal Sum Arrays With Minimum Number of Operations
mediumHow to solve LeetCode 1775 using a greedy approach with counting sort. Minimize operations by always making the highest-impact change first.
Determine if String Halves Are Alike: Vowel Counting
easyHow to solve LeetCode 1704 Determine if String Halves Are Alike. Split the string, count vowels in each half, and compare.
Decode XORed Permutation: XOR Properties for Recovery
mediumHow to solve LeetCode 1734 Decode XORed Permutation using XOR cancellation and odd-length permutation properties. Bit manipulation approach explained.
Decode XORed Array: XOR Inverse Property
easyHow to solve LeetCode 1720 Decode XORed Array using the XOR inverse property. Bit manipulation pattern explained with visual walkthroughs.
Count Ways to Make Array With Product: Prime Factorization and Combinatorics
hardHow 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.
Count Number of Homogenous Substrings: Group Counting Pattern
mediumHow to solve LeetCode 1759 Count Number of Homogenous Substrings using group counting. Count consecutive runs and apply the triangular number formula.
Count Items Matching a Rule: Linear Scan Pattern
easyHow to solve LeetCode 1773 Count Items Matching a Rule with a simple linear scan. A clean introduction to filtering arrays by attribute.
Count Good Meals: Hash Map with Powers of Two
mediumHow to solve LeetCode 1711 Count Good Meals. Use a hash map to count pairs whose sum is a power of two.
Construct the Lexicographically Largest Valid Sequence: Backtracking
mediumHow to solve LeetCode 1718 Construct the Lexicographically Largest Valid Sequence using greedy backtracking. Visual walkthrough of the placement strategy.
Closest Subsequence Sum: Meet in the Middle
hardHow to solve LeetCode 1755 Closest Subsequence Sum using meet in the middle. Splitting the search space to find the closest sum explained visually.
Closest Dessert Cost: Backtracking with Pruning
mediumHow to solve LeetCode 1774 Closest Dessert Cost using backtracking with early pruning. A visual guide to exploring the topping decision tree.
Checking Existence of Edge Length Limited Paths: Offline Union-Find
hardHow to solve LeetCode 1697 using sorted queries and union-find. Learn the offline query processing pattern with visual walkthroughs.
Check if Array Is Sorted and Rotated: Counting Inversions
easyHow to solve LeetCode 1752 Check if Array Is Sorted and Rotated by counting order breaks. A clean single-pass approach explained visually.
Change Minimum Characters to Satisfy One of Three Conditions
mediumHow to solve LeetCode 1737 using character frequency counting. Learn the prefix sum approach to efficiently evaluate all three conditions.
Cat and Mouse II: Game Theory on a Grid
hardHow to solve LeetCode 1728 Cat and Mouse II using game theory with memoization. The minimax approach on grid states explained with visual walkthroughs.
Can You Eat Your Favorite Candy on Your Favorite Day: Prefix Sum Range Check
mediumHow to solve LeetCode 1744 Can You Eat Your Favorite Candy on Your Favorite Day using prefix sums and range overlap. Clean visual explanation.
Calculate Money in Leetcode Bank: Weekly Deposit Pattern
easyHow to solve LeetCode 1716 Calculate Money in Leetcode Bank using math. The arithmetic series pattern explained with visual walkthroughs.
Building Boxes: Minimum Floor Boxes in a Corner Pyramid
hardHow 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.
Average Waiting Time: Greedy Simulation
mediumHow to solve LeetCode 1701 Average Waiting Time by tracking chef availability. A clean simulation pattern for sequential processing.
Widest Vertical Area Between Two Points Containing No Points
easyHow to solve LeetCode 1637 Widest Vertical Area Between Two Points Containing No Points. Sort x-coordinates and find the maximum gap between consecutive values.
Ways to Make a Fair Array: Prefix Sum Trick
mediumHow to solve LeetCode 1664 Ways to Make a Fair Array using prefix sums. Visual walkthrough of even/odd index tracking after element removal.
Sum of Absolute Differences in a Sorted Array: Prefix Sum Trick
mediumHow 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.
Stone Game VII: Dynamic Programming on Subarrays
mediumHow to solve LeetCode 1690 Stone Game VII using dynamic programming. Optimal game theory with interval DP explained visually.
Stone Game VI: Greedy Selection by Combined Value
mediumHow to solve LeetCode 1686 Stone Game VI. Sort stones by combined Alice and Bob values to find the optimal greedy picking strategy.
Sort Array by Increasing Frequency: Custom Sorting with Frequency Counts
easyHow to solve LeetCode 1636 Sort Array by Increasing Frequency. Count element frequencies and use a custom comparator to sort by frequency ascending, value descending.
Smallest String With A Given Numeric Value: Greedy from the Right
mediumHow 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.
Slowest Key: Finding the Longest Key Press
easyHow to solve LeetCode 1629 Slowest Key. Compute each key's press duration from release times and track the maximum with tie-breaking.
Sell Diminishing-Valued Colored Balls: Greedy Leveling Pattern
mediumHow to solve LeetCode 1648 Sell Diminishing-Valued Colored Balls using sorting and greedy leveling. Maximize profit by always selling the most valuable ball.
Richest Customer Wealth: Matrix Row Sum Pattern
easyHow to solve LeetCode 1672 Richest Customer Wealth by summing matrix rows. The row aggregation pattern explained with visual walkthroughs.
Reformat Phone Number: String Grouping Pattern
easyHow to solve LeetCode 1694 Reformat Phone Number with clean string processing. The digit grouping pattern explained visually.
Rank Transform of a Matrix: Union-Find with Greedy Ranking
hardHow 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.
Path With Minimum Effort: Binary Search on the Answer
mediumHow to solve LeetCode 1631 Path With Minimum Effort. Use binary search on the effort threshold combined with BFS to find the optimal path.
Partitioning Into Minimum Number of Deci-Binary Numbers: Find the Max Digit
mediumHow 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.
Number of Ways to Form a Target String Given a Dictionary
hardHow 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.
Minimum Operations to Reduce X to Zero: Sliding Window Complement
mediumHow 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.
Minimum Number of Removals to Make Mountain Array: LIS + LDS Pattern
hardHow 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.
Minimum Moves to Make Array Complementary: Difference Array Pattern
mediumHow 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.
Minimum Jumps to Reach Home: BFS with Directional State
mediumHow 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.
Minimum Initial Energy to Finish Tasks: Greedy Sorting
hardHow to solve LeetCode 1665 Minimum Initial Energy to Finish Tasks with a greedy approach. Visual walkthrough of sorting by energy surplus.
Minimum Incompatibility: Bitmask DP for Subset Partitioning
hardHow to solve LeetCode 1681 Minimum Incompatibility using bitmask dynamic programming. The subset enumeration and partitioning pattern explained.
Minimum Deletions to Make String Balanced: Counting B's as You Go
mediumHow 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.
Minimum Deletions to Make Character Frequencies Unique: Greedy Frequency Counting
mediumHow to solve LeetCode 1647 Minimum Deletions to Make Character Frequencies Unique using a greedy approach with frequency counting and sorting.
Minimize Deviation in Array: Max Heap Greedy Pattern
hardHow to solve LeetCode 1675 Minimize Deviation in Array using a max heap with normalization. The greedy shrinking pattern explained with visual walkthroughs.
Merge In Between Linked Lists: Pointer Surgery
mediumHow to solve LeetCode 1669 Merge In Between Linked Lists with pointer manipulation. Visual walkthrough of splicing one list into another.
Maximum Repeating Substring: Simple String Matching
easyHow to solve LeetCode 1668 Maximum Repeating Substring by incrementally building repeated patterns. Visual step-by-step walkthrough.
Maximum Height by Stacking Cuboids: DP with Sorting
hardHow to solve LeetCode 1691 Maximum Height by Stacking Cuboids using dynamic programming and sorting. The cuboid stacking pattern explained visually.
Maximum Erasure Value: Sliding Window with Unique Elements
mediumHow to solve LeetCode 1695 Maximum Erasure Value using the sliding window pattern with a set. Finding the maximum sum subarray with unique elements.
Maximize Grid Happiness: Profile DP with Bitmask
hardHow to solve LeetCode 1659 Maximize Grid Happiness using profile dynamic programming. Place introverts and extroverts on a grid to maximize total happiness.
Max Number of K-Sum Pairs: Hash Map Complement Counting
mediumHow to solve LeetCode 1679 Max Number of K-Sum Pairs using hash map complement counting. Two approaches compared: hash map and two pointers.
Kth Smallest Instructions: Combinatorial Path Counting
hardHow to solve LeetCode 1643 Kth Smallest Instructions using combinatorics. Build the lexicographically k-th smallest path string one character at a time.
Jump Game VI: DP with Sliding Window Maximum
mediumHow to solve LeetCode 1696 Jump Game VI using dynamic programming with a monotonic deque. The sliding window maximum optimization explained visually.
Goal Parser Interpretation: String Replacement Patterns
easyHow to solve LeetCode 1678 Goal Parser Interpretation using simple string parsing. The character-by-character replacement pattern explained.
Get Maximum in Generated Array: Simulation Pattern
easyHow to solve LeetCode 1646 Get Maximum in Generated Array using simulation. Build the array step by step and track the maximum.
Furthest Building You Can Reach: Greedy Heap Pattern
mediumHow 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.
Find the Most Competitive Subsequence: Monotonic Stack Pattern
mediumHow 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.
Distribute Repeating Integers: Bitmask DP over Customer Subsets
hardHow 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.
Determine if Two Strings Are Close: Frequency Matching Pattern
mediumHow to solve LeetCode 1657 Determine if Two Strings Are Close using character frequency analysis. Learn when two strings can be transformed into each other.
Design Front Middle Back Queue: Two Deques
mediumHow to solve LeetCode 1670 Design Front Middle Back Queue using two balanced deques. Visual walkthrough of O(1) operations at front, middle, and back.
Delivering Boxes from Storage to Ports: Sliding Window DP
hardHow to solve LeetCode 1687 Delivering Boxes from Storage to Ports. Combine dynamic programming with a sliding window and monotonic deque to minimize delivery trips.
Defuse the Bomb: Circular Sliding Window
easyHow 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.
Create Sorted Array through Instructions: Fenwick Tree for Insertion Costs
hardHow 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.
Count the Number of Consistent Strings: Set Membership Patterns
easyHow to solve LeetCode 1684 Count the Number of Consistent Strings using set membership checking. The allowed character set pattern explained.
Count Substrings That Differ by One Character
mediumHow to solve LeetCode 1638 Count Substrings That Differ by One Character. Fix the mismatch position and expand to count valid pairs efficiently.
Count Sorted Vowel Strings
mediumHow to solve LeetCode 1641 Count Sorted Vowel Strings. Use dynamic programming or combinatorics to count lexicographically sorted vowel strings of length n.
Count of Matches in Tournament: Every Match Eliminates One
easyHow to solve LeetCode 1688 Count of Matches in Tournament. Recognize that each match eliminates exactly one team, making the answer always n minus 1.
Concatenation of Consecutive Binary Numbers: Bit Shifting Patterns
mediumHow to solve LeetCode 1680 Concatenation of Consecutive Binary Numbers using bit shifting. The modular arithmetic pattern explained.
Check If Two String Arrays are Equivalent: Pointer Technique
easyHow to solve LeetCode 1662 Check If Two String Arrays are Equivalent using O(1) space with four pointers. Compare concatenated strings without building them.
Check Array Formation Through Concatenation
easyHow to solve LeetCode 1640 Check Array Formation Through Concatenation. Use a hash map from first elements to pieces for efficient matching.
Arithmetic Subarrays: Checking Subarrays for Arithmetic Sequences
mediumHow to solve LeetCode 1630 Arithmetic Subarrays. Extract, sort, and verify constant differences for each query range.
Throne Inheritance: Tree Design with Pre-Order DFS
mediumHow to solve LeetCode 1600 Throne Inheritance using tree traversal and pre-order DFS. Design a system that tracks family hierarchy and inheritance order.
Three Consecutive Odds: Simple Array Scanning
easyHow to solve LeetCode 1550 Three Consecutive Odds by counting consecutive odd numbers. A clean scanning approach with visual walkthrough.
Thousand Separator: String Building from Right to Left
easyHow to solve LeetCode 1556 Thousand Separator by grouping digits from the right. A clean string manipulation approach with visual walkthrough.
Sum of All Odd Length Subarrays: Count Each Element's Contribution
easyHow 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).
Strange Printer II: Topological Sort on Color Dependencies
hardHow to solve LeetCode 1591 Strange Printer II. Model color overlaps as a dependency graph and check for a valid print order with topological sort.
Stone Game V: Interval DP with Prefix Sums
hardHow to solve LeetCode 1563 Stone Game V using interval dynamic programming and prefix sums. Visual walkthrough and clean Python solution.
Split Two Strings to Make Palindrome: Two-Pointer Pattern
mediumHow to solve LeetCode 1616 Split Two Strings to Make Palindrome using two pointers. Visual walkthrough and clean Python solution.
Split a String Into the Max Number of Unique Substrings: Backtracking with a Set
mediumHow 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.
Special Positions in a Binary Matrix: Row and Column Sum Trick
easyHow to solve LeetCode 1582 Special Positions in a Binary Matrix using precomputed row and column sums. Visual walkthrough and clean Python solution.
Special Array With X Elements Greater Than or Equal X: Sorting and Counting
easyHow 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.
Shortest Subarray to be Removed to Make Array Sorted
mediumHow 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.
Replace All ?'s to Avoid Consecutive Repeating Characters
easyHow 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.
Remove Max Number of Edges to Keep Graph Fully Traversable
hardHow to solve LeetCode 1579 using Union-Find with edge prioritization. Visual walkthrough of the greedy graph connectivity approach.
Rearrange Spaces Between Words: Distributing Spaces Evenly
easyHow 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.
Number of Ways Where Square of Number Is Equal to Product of Two Numbers
mediumHow 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.
Number of Ways to Split a String: Counting Splits with Equal Ones
mediumHow 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.
Number of Sets of K Non-Overlapping Line Segments: DP on Segments
mediumHow to solve LeetCode 1621 Number of Sets of K Non-Overlapping Line Segments using dynamic programming. Visual walkthrough and clean Python solution.
Most Visited Sector in a Circular Track: Skip the Simulation
easyHow to solve LeetCode 1560 Most Visited Sector in a Circular Track without simulating every lap. A clean observation-based approach with visual walkthrough.
Minimum Time to Make Rope Colorful: Greedy Group Processing
mediumHow to solve LeetCode 1578 Minimum Time to Make Rope Colorful using greedy processing of consecutive groups. Visual walkthrough and clean Python solution.
Minimum Operations to Make Array Equal: Math Pattern
mediumHow to solve LeetCode 1551 Minimum Operations to Make Array Equal using a closed-form math formula. From pairing to O(1) solution.
Minimum Numbers of Function Calls to Make Target Array: Reverse Engineering with Bits
mediumHow 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.
Minimum Number of Vertices to Reach All Nodes: Find the Sources
mediumHow 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.
Minimum Number of Days to Eat N Oranges: BFS with Memoization
hardHow to solve LeetCode 1553 Minimum Number of Days to Eat N Oranges using BFS with memoization. Pruning a massive search space with greedy division.
Minimum Number of Days to Disconnect Island: The Answer Is Always 0, 1, or 2
hardHow to solve LeetCode 1568 Minimum Number of Days to Disconnect Island using connected component analysis. Visual walkthrough and clean Python solution.
Minimum Cost to Cut a Stick: Interval DP on Segment Boundaries
hardHow 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.
Minimum Cost to Connect Two Groups of Points: Bitmask DP
hardHow to solve LeetCode 1595 Minimum Cost to Connect Two Groups of Points using bitmask DP. Ensure every point in both groups is connected.
Min Cost to Connect All Points: Minimum Spanning Tree
mediumHow to solve LeetCode 1584 Min Cost to Connect All Points using Kruskal's algorithm with Union-Find. Visual walkthrough of the MST construction.
Mean of Array After Removing Some Elements: Trimmed Mean
easyHow to solve LeetCode 1619 Mean of Array After Removing Some Elements. Sort, trim 5% from each end, and compute the mean.
Maximum Profit of Operating a Centennial Wheel: Simulation
mediumHow to solve LeetCode 1599 Maximum Profit of Operating a Centennial Wheel using simulation. Track profit at each rotation to find the optimal stopping point.
Maximum Number of Visible Points: Angle Sweep with Sliding Window
hardHow to solve LeetCode 1610 Maximum Number of Visible Points using atan2 angle conversion, sorting, and a sliding window for circular ranges.
Maximum Number of Non-Overlapping Subarrays With Sum Equals Target
mediumHow 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.
Maximum Number of Coins You Can Get: Greedy Triplet Picking
mediumHow 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.
Maximum Number of Achievable Transfer Requests: Backtracking with Bitmask Enumeration
hardHow to solve LeetCode 1601 Maximum Number of Achievable Transfer Requests using backtracking and bitmask enumeration. The subset enumeration pattern explained with visual walkthroughs.
Maximum Non Negative Product in a Matrix: Dual-Tracking Grid DP
mediumHow to solve LeetCode 1594 Maximum Non Negative Product in a Matrix using dynamic programming. Track both max and min products through the grid.
Maximum Nesting Depth of the Parentheses: Counter Pattern
easyHow to solve LeetCode 1614 Maximum Nesting Depth of the Parentheses. Track depth with a counter instead of a stack for O(1) space.
Maximum Length of Subarray With Positive Product: Tracking Sign Flips
mediumHow 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.
Maximal Network Rank: Graph Degree Counting
mediumHow to solve LeetCode 1615 Maximal Network Rank by counting node degrees and checking shared edges. A clean graph problem explained visually.
Matrix Diagonal Sum: Primary and Secondary Diagonals
easyHow to solve LeetCode 1572 Matrix Diagonal Sum by iterating once and summing both diagonals. Visual walkthrough and clean Python solution.
Make The String Great: Stack-Based Pair Removal
easyHow 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.
Make Sum Divisible by P: Prefix Sums and Modular Lookups
mediumHow 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.
Magnetic Force Between Two Balls: Binary Search on Answer
mediumHow to solve LeetCode 1552 Magnetic Force Between Two Balls using binary search on the minimum distance. The binary search on answer pattern explained.
Lexicographically Smallest String After Applying Operations: BFS State Exploration
mediumHow to solve LeetCode 1625 using BFS to explore all reachable string states through add and rotate operations. A clean walkthrough of state-space search.
Largest Substring Between Two Equal Characters: Hash Map First Occurrence
easyHow 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.
Graph Connectivity With Threshold: Sieve Meets Union-Find
hardHow to solve LeetCode 1627 Graph Connectivity With Threshold using a sieve-based Union-Find approach. Number theory and graph connectivity explained visually.
Find Valid Matrix Given Row and Column Sums: Greedy Cell-by-Cell Construction
mediumHow 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.
Find Servers That Handled Most Number of Requests: Heap with Sorted Set
hardHow 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.
Find Longest Awesome Substring: Bitmask Parity for Palindrome Substrings
hardHow 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.
Find Latest Group of Size M: Reverse Simulation with Group Tracking
mediumHow to solve LeetCode 1562 Find Latest Group of Size M using reverse simulation and group size tracking. Visual walkthrough and clean Python solution.
Find Kth Bit in Nth Binary String
mediumHow 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.
Fancy Sequence: Lazy Math with Modular Inverse
hardHow to solve LeetCode 1622 Fancy Sequence using modular inverse and lazy propagation. A clean design problem explained visually.
Even Odd Tree: Level-Order Validation
mediumHow 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.
Detect Cycles in 2D Grid: Union-Find on a Matrix
mediumHow 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.
Design Parking System: Simple Counter Pattern
easyHow to solve LeetCode 1603 Design Parking System using simple counters. A clean design problem explained with visual walkthroughs.
Crawler Log Folder: Depth Tracking with a Counter
easyHow to solve LeetCode 1598 Crawler Log Folder by tracking directory depth. A simple stack or counter approach explained with visuals.
Count Subtrees With Max Distance Between Cities: Bitmask Enumeration
hardHow to solve LeetCode 1617 Count Subtrees With Max Distance Between Cities using bitmask enumeration and BFS. Visual walkthrough and clean Python solution.
Count All Possible Routes: DP on City and Fuel
hardHow to solve LeetCode 1575 Count All Possible Routes with memoized DP. Visual walkthrough of the two-dimensional state space over cities and fuel.
Coordinate With Maximum Network Quality: Brute Force Simulation
mediumHow to solve LeetCode 1620 Coordinate With Maximum Network Quality using brute force enumeration. Visual walkthrough and clean Python solution.
Check If String Is Transformable With Substring Sort Operations
hardHow to solve LeetCode 1585 using digit queues and greedy validation. Visual walkthrough of the substring sort transformation check.
Best Team With No Conflicts: Sorting Meets LIS-Style DP
mediumHow to solve LeetCode 1626 Best Team With No Conflicts using sorting and longest increasing subsequence dynamic programming. Step-by-step visual walkthrough.
Alert Using Same Key-Card Three or More Times: Hash Map Grouping with Sliding Window
mediumHow 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.
XOR Operation in an Array: Bit Manipulation Basics
easyHow to solve LeetCode 1486 XOR Operation in an Array. Build the array and XOR all elements together.
Water Bottles: Simulation and Math
easyHow to solve LeetCode 1518 Water Bottles. Visual walkthrough of the bottle exchange simulation.
The kth Factor of n: Efficient Factor Enumeration
mediumHow to solve LeetCode 1492 The kth Factor of n by iterating up to sqrt(n) to find factors in sorted order.
The k Strongest Values in an Array: Two-Pointer Selection
mediumHow 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.
Subrectangle Queries: Design a 2D Matrix Updater
mediumHow to solve LeetCode 1476 Subrectangle Queries by designing a class that updates rectangular regions and queries cell values. Clean solution explained step by step.
String Compression II: DP on Run-Length Encoding
hardHow to solve LeetCode 1531 String Compression II using dynamic programming to minimize run-length encoded length after deletions.
Stone Game IV: Game Theory Meets Dynamic Programming
hardHow to solve LeetCode 1510 Stone Game IV. Visual DP walkthrough for game states with perfect square moves.
Shuffle the Array: Interleaving Two Halves in Place
easyHow to solve LeetCode 1470 Shuffle the Array by interleaving elements from two halves. Clean O(n) solution explained step by step.
Shuffle String: Index Mapping Pattern
easyHow to solve LeetCode 1528 Shuffle String using direct index mapping. The permutation placement pattern explained with visual walkthroughs.
Running Sum of 1d Array: Your First Prefix Sum
easyHow to solve LeetCode 1480 Running Sum of 1d Array with prefix sums. Clean O(n) solution explained step by step.
Reorder Routes to Make All Paths Lead to City Zero: BFS on Directed Trees
mediumHow 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.
Reformat Date
easyHow to solve LeetCode 1507 Reformat Date with string parsing and formatting. A clean approach to date conversion problems.
Range Sum of Sorted Subarray Sums
mediumHow to solve LeetCode 1508 Range Sum of Sorted Subarray Sums. Generate all subarray sums, sort, and sum a range.
Probability of Two Boxes Having the Same Number of Distinct Balls: Combinatorial Backtracking
hardHow to solve LeetCode 1467 Probability of a Two Boxes Having the Same Number of Distinct Balls using backtracking with multinomial coefficients.
Path with Maximum Probability: Modified Dijkstra's Algorithm
mediumHow to solve LeetCode 1514 Path with Maximum Probability. Visual walkthrough of Dijkstra's with probability multiplication.
Path Crossing: Hash Set Coordinate Tracking
easyHow to solve LeetCode 1496 Path Crossing using a hash set to detect revisited coordinates. Track movements on a 2D grid with O(n) time.
Parallel Courses II: Bitmask DP for Course Scheduling
hardHow to solve LeetCode 1494 Parallel Courses II using bitmask dynamic programming to find the minimum number of semesters.
Paint House III: Neighborhood-Constrained DP
hardHow to solve LeetCode 1473 Paint House III using 3D dynamic programming with house, color, and neighborhood count dimensions. Step-by-step explanation.
Number of Substrings With Only 1s: Counting Consecutive Groups
mediumHow to solve LeetCode 1513 Number of Substrings With Only 1s using consecutive counting and the n*(n+1)/2 formula.
Number of Substrings With Only 1s: Counting Consecutive Groups
mediumHow to solve LeetCode 1513 Number of Substrings With Only 1s. Visual walkthrough of the consecutive counting pattern.
Number of Subsequences That Satisfy the Given Sum Condition: Sort and Two Pointers
mediumHow to solve LeetCode 1498 using sorting and two pointers to count valid subsequences. Combine binary search intuition with modular exponentiation.
Number of Sub-arrays With Odd Sum: Prefix Sum Parity
mediumHow to solve LeetCode 1524 Number of Sub-arrays With Odd Sum. Track prefix sum parity to count subarrays with odd sums in O(n).
Number of Nodes in the Sub-Tree With the Same Label
mediumHow 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.
Number of Good Ways to Split a String: Prefix-Suffix Distinct Counting
mediumHow 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.
Number of Good Leaf Nodes Pairs: DFS Distance Propagation
mediumHow to solve LeetCode 1530 Number of Good Leaf Nodes Pairs using DFS with distance list propagation.
Minimum Swaps to Arrange a Binary Grid: Greedy Row Swap Pattern
mediumHow to solve LeetCode 1536 Minimum Swaps to Arrange a Binary Grid using a greedy approach with trailing zeros. Visual walkthrough and clean Python solution.
Minimum Suffix Flips: Greedy State Tracking
mediumHow to solve LeetCode 1529 Minimum Suffix Flips using greedy state tracking. The suffix flip counting pattern explained with visual walkthroughs.
Minimum Increments on Subarrays to Form a Target Array: Greedy Stacking
hardHow 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.
Minimum Number of Days to Make m Bouquets: Binary Search on Answer
mediumHow to solve LeetCode 1482 using binary search on the answer. Learn to identify when to binary search over the solution space.
Minimum Insertions to Balance a Parentheses String: Greedy Counter Pattern
mediumHow to solve LeetCode 1541 Minimum Insertions to Balance a Parentheses String using greedy counting. Visual walkthrough and clean Python solution.
Minimum Difference Between Largest and Smallest Value in Three Moves
mediumHow to solve LeetCode 1509 Minimum Difference Between Largest and Smallest Value in Three Moves. Sort and check four windows.
Maximum Product of Two Elements in an Array: Finding the Top Two
easyHow to solve LeetCode 1464 Maximum Product of Two Elements in an Array by tracking the two largest values in a single pass.
Maximum Number of Non-Overlapping Substrings: Greedy Interval Selection on Strings
hardHow to solve LeetCode 1520 Maximum Number of Non-Overlapping Substrings. Expand character intervals, validate them, and greedily pick non-overlapping ones.
Maximum Area of a Piece of Cake After Cuts: Greedy Gap Finding
mediumHow 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.
Max Value of Equation: Monotone Deque Optimization
hardHow 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).
Making File Names Unique: Hash Map Tracking
mediumHow to solve LeetCode 1487 Making File Names Unique using a hash map to track used names and next available suffix.
Longest Subarray of 1's After Deleting One Element: Sliding Window
mediumHow to solve LeetCode 1493 Longest Subarray of 1's After Deleting One Element using a sliding window that tolerates at most one zero.
Least Number of Unique Integers after K Removals: Greedy Frequency Pruning
mediumHow to solve LeetCode 1481 Least Number of Unique Integers after K Removals using frequency counting and greedy removal. Clean solution explained step by step.
Last Moment Before All Ants Fall Out of a Plank
mediumHow 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.
Kth Missing Positive Number: Binary Search on Missing Counts
easyHow to solve LeetCode 1539 Kth Missing Positive Number using binary search on the count of missing values. Visual walkthrough and clean Python solution.
Kth Ancestor of a Tree Node: Binary Lifting
hardHow to solve LeetCode 1483 using binary lifting. Precompute ancestors at powers of 2 to answer ancestor queries in O(log k) time.
Get the Maximum Score: Two-Pointer Path Switching
hardHow to solve LeetCode 1537 Get the Maximum Score using two pointers and greedy path selection at intersections. Visual walkthrough and Python solution.
Find Two Non-overlapping Sub-arrays Each With Target Sum: Sliding Window Meets Prefix Minimum
mediumHow 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.
Find the Winner of an Array Game: Simulation with Early Exit
mediumHow to solve LeetCode 1535 Find the Winner of an Array Game using simulation with an optimization for large k.
Find Critical and Pseudo-Critical Edges in MST: Union-Find Classification
hardHow 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.
Find a Value of a Mysterious Function Closest to Target: Bit-Bounded Set Propagation
hardHow 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.
Final Prices With a Special Discount: Monotonic Stack Basics
easyHow 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.
Design Browser History: Stack-Based Navigation
mediumHow to solve LeetCode 1472 Design Browser History using a list with a pointer. Clean O(1) operations explained step by step.
Count Submatrices With All Ones
mediumHow to solve LeetCode 1504 Count Submatrices With All Ones using consecutive-ones prefix and upward expansion.
Count Odd Numbers in an Interval Range: A Math Shortcut
easyHow to solve LeetCode 1523 Count Odd Numbers in an Interval Range. Use floor division to count odd numbers between two endpoints in O(1).
Count Good Triplets: Triple Loop with Conditions
easyHow to solve LeetCode 1534 Count Good Triplets using a triple loop approach with absolute difference conditions.
Cherry Pickup II: Two Robots Collecting Maximum Cherries
hardHow to solve LeetCode 1463 Cherry Pickup II using dynamic programming with two robots moving through a grid simultaneously.
Check If Array Pairs Are Divisible by k: Remainder Counting
mediumHow to solve LeetCode 1497 using remainder frequency counting. Pair elements whose remainders sum to k for O(n) validation.
Can Make Arithmetic Progression From Sequence: Sort and Verify
easyHow to solve LeetCode 1502 by sorting and checking consecutive differences. A clean O(n log n) approach to validate arithmetic progressions.
Can Convert String in K Moves: Shift Counting Pattern
mediumHow to solve LeetCode 1540 Can Convert String in K Moves using character shift differences and move assignment. Visual walkthrough and Python solution.
Best Position for a Service Centre: The Geometric Median
hardHow to solve LeetCode 1515 Best Position for a Service Centre. Visual walkthrough of Weiszfeld's algorithm for the geometric median.
Avoid Flood in The City: Greedy Dry Day Assignment
mediumHow to solve LeetCode 1488 Avoid Flood in The City using hash maps and a sorted set of dry days for greedy assignment.
Average Salary Excluding Min and Max: Single Pass Array Scan
easyHow to solve LeetCode 1491 Average Salary Excluding the Minimum and Maximum Salary with a single pass to find min, max, and sum.
Allocate Mailboxes: DP Meets the Median Trick
hardHow to solve LeetCode 1478 Allocate Mailboxes using dynamic programming with median optimization. Clean solution explained step by step.
The k-th Happy String of Length n: Backtracking with Pruning
mediumHow to solve LeetCode 1415 using backtracking to generate happy strings in lexicographical order. Skip directly to the k-th result.
String Matching in an Array: Substring Detection
easyHow to solve LeetCode 1408 String Matching in an Array by checking all pairs for substring relationships. Visual walkthrough with Python solution.
Stone Game III: Optimal Play with Suffix DP
hardHow to solve LeetCode 1406 Stone Game III using suffix sum DP and minimax reasoning. Visual walkthrough of the state transitions with Python solution.
Simplified Fractions: GCD-Based Enumeration
mediumHow to solve LeetCode 1447 Simplified Fractions using GCD to enumerate all proper fractions in lowest terms. Learn the GCD filtering pattern with visual walkthroughs.
Restore The Array: String Partition DP
hardHow to solve LeetCode 1416 using dynamic programming to count valid ways to split a digit string into numbers between 1 and k.
Reformat The String: Interleaving Letters and Digits
easyHow to solve LeetCode 1417 Reformat The String. Separate characters by type and interleave them, placing the larger group first.
Reducing Dishes: Greedy Sorting for Maximum Satisfaction
hardHow 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.
Rearrange Words in a Sentence: Stable Sort by Length
mediumHow to solve LeetCode 1451 Rearrange Words in a Sentence using stable sort. Visual walkthrough of sorting words by length while preserving order.
Queries on a Permutation With Key: Simulate and Track
mediumHow to solve LeetCode 1409 Queries on a Permutation With Key using direct simulation. Visual walkthrough of the move-to-front operation with Python solution.
Pseudo-Palindromic Paths in a Binary Tree: Bit Manipulation on Tree Paths
mediumHow 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.
Pizza With 3n Slices: Circular DP Selection
hardHow 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.
Favorite Companies: Subset Checking with Sets
mediumHow to solve LeetCode 1452 People Whose List of Favorite Companies Is Not a Subset of Another List using set operations and pairwise comparison.
Number of Ways to Wear Different Hats: Bitmask DP Pattern
hardHow to solve LeetCode 1434 Number of Ways to Wear Different Hats to Each Other using bitmask dynamic programming.
Number of Ways to Paint N x 3 Grid: Row State DP
hardHow to solve LeetCode 1411 using dynamic programming with row state transitions. Track pattern types across rows to count valid colorings.
Number of Ways of Cutting a Pizza
hardHow 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.
Number of Students Doing Homework at a Given Time: Interval Containment Check
easyHow 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.
Number of Steps to Reduce a Number in Binary Representation to One
mediumHow 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.
Minimum Value to Get Positive Step by Step Sum: Prefix Sum Pattern
easyHow to solve LeetCode 1413 by computing prefix sums and finding the minimum. A clean application of the prefix sum pattern.
Minimum Time to Collect All Apples in a Tree
mediumHow 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.
Minimum Subsequence in Non-Increasing Order
easyHow 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.
Minimum Number of Frogs Croaking: Tracking Concurrent Sequences
mediumHow 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.
Maximum Score After Splitting a String: Counting Zeros and Ones
easyHow 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.
Maximum Points You Can Obtain from Cards: Sliding Window on Edges
mediumHow to solve LeetCode 1423 Maximum Points You Can Obtain from Cards using a sliding window minimum approach. Visual walkthrough and clean Python solution.
Maximum Vowels in a Substring: Sliding Window Pattern
mediumHow 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.
Maximum Darts in a Circular Dartboard: Angular Sweep
hardHow to solve LeetCode 1453 Maximum Number of Darts Inside of a Circular Dartboard using angular sweep and geometry. Hard math problem explained visually.
Max Dot Product of Two Subsequences: 2D DP Pattern
hardHow 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.
Max Difference You Can Get From Changing an Integer: Greedy Digit Replacement
mediumHow to solve LeetCode 1432 Max Difference You Can Get From Changing an Integer using greedy digit replacement. Visual walkthrough and clean Python solution.
Make Two Arrays Equal by Reversing Subarrays: Frequency Count Pattern
easyHow 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.
Longest Happy String: Greedy Heap Construction
mediumHow to solve LeetCode 1405 Longest Happy String using a greedy approach with a max heap. Visual walkthrough of character selection with Python solution.
Longest Happy Prefix: KMP Failure Function
hardHow to solve LeetCode 1392 Longest Happy Prefix using the KMP failure function to find the longest proper prefix that is also a suffix.
Longest Continuous Subarray With Absolute Diff at Most Limit: Monotonic Deque Pattern
mediumHow to solve LeetCode 1438 using a sliding window with two monotonic deques to track the running min and max.
Kids With the Greatest Number of Candies: Find Max and Compare
easyHow to solve LeetCode 1431 Kids With the Greatest Number of Candies. A clean one-pass solution with visual walkthrough.
HTML Entity Parser: String Replacement with a Map
mediumHow 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.
Four Divisors: Efficient Divisor Counting
mediumHow to solve LeetCode 1390 Four Divisors by efficiently finding and counting divisors using square root optimization.
Form Largest Integer With Digits That Add up to Target: DP Greedy Reconstruction
hardHow 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.
Find Minimum Fibonacci Numbers Whose Sum Is K: Greedy Decomposition
mediumHow to solve LeetCode 1414 using a greedy approach with Fibonacci numbers. Always pick the largest Fibonacci number that fits.
Find the Kth Smallest Sum of a Matrix With Sorted Rows
hardHow to solve LeetCode 1439. Use a min-heap to efficiently enumerate matrix row sums from smallest to largest without generating all combinations.
Find Lucky Integer in an Array: Frequency Counting Made Simple
easyHow 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.
Find All Good Strings: Digit DP Meets KMP
hardHow 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.
Display Table of Food Orders in a Restaurant: Organizing with Hash Maps
mediumHow 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.
Diagonal Traverse II: Grouping by Anti-Diagonals
mediumHow to solve LeetCode 1424 Diagonal Traverse II using anti-diagonal grouping. Visual walkthrough for jagged 2D array diagonal traversal.
Destination City: Hash Set Lookup Pattern
easyHow to solve LeetCode 1436 Destination City using a hash set to find the city with no outgoing path.
Design Underground System: Two Hash Maps for Travel Time Tracking
mediumHow to solve LeetCode 1396 Design Underground System using two hash maps to track passenger check-ins and aggregate route travel times.
Create Target Array in the Given Order: Simulation Pattern
easyHow to solve LeetCode 1389 Create Target Array in the Given Order using list insertion simulation.
Course Schedule IV: Transitive Closure with Floyd-Warshall
mediumHow to solve LeetCode 1462 Course Schedule IV using Floyd-Warshall to build a reachability matrix. Precompute all prerequisite relationships for constant-time queries.
Count Triplets That Can Form Two Arrays of Equal XOR
mediumHow 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.
Count Number of Teams: Fix the Middle Element
mediumHow to solve LeetCode 1395 Count Number of Teams by fixing the middle element and counting contributions from both sides.
Count Largest Group: Digit Sum Grouping
easyHow 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.
Count Good Nodes in Binary Tree: DFS with Path Maximum
mediumHow 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.
Construct K Palindrome Strings: Counting Odd Frequencies
mediumHow to solve LeetCode 1400 Construct K Palindrome Strings using character frequency counting. The greedy insight that connects odd-frequency characters to palindrome feasibility.
Constrained Subsequence Sum: DP with Monotonic Deque
hardHow to solve LeetCode 1425 Constrained Subsequence Sum using dynamic programming with a monotonic deque. Visual walkthrough and clean Python solution.
Consecutive Characters: Finding the Power of a String
easyHow to solve LeetCode 1446 Consecutive Characters with a single-pass scan. Learn the streak-counting pattern with visual walkthroughs.
Circle and Rectangle Overlapping: Closest Point Distance Check
mediumHow 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.
Check if There is a Valid Path in a Grid: Pipe Connection BFS
mediumHow to solve LeetCode 1391 Check if There is a Valid Path in a Grid using BFS with directional connection validation.
Check If All 1s Are at Least Length K Places Away: Linear Scan Pattern
easyHow to solve LeetCode 1437 Check If All 1's Are at Least Length K Places Away with a single pass through the array.
Check If a Word Occurs As a Prefix: String Scanning
easyHow to solve LeetCode 1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence. Simple string prefix matching explained visually.
Check If a String Contains All Binary Codes of Size K: Sliding Window + HashSet
mediumHow 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.
Check If a String Can Break Another String: Sorted Comparison Pattern
mediumHow to solve LeetCode 1433 Check If a String Can Break Another String using sorting and greedy comparison.
Build Array Where You Can Find The Maximum Exactly K Comparisons: 3D Dynamic Programming
hardHow 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.
Build an Array With Stack Operations
mediumHow to solve LeetCode 1441. Simulate Push and Pop operations on a stack to match a target array from a stream of consecutive integers.
Validate Binary Tree Nodes: In-Degree + BFS
mediumHow 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.
Tweet Counts Per Frequency: Design with Sorted Buckets
mediumHow to solve LeetCode 1348 Tweet Counts Per Frequency. Design a data structure to record tweets and query counts by minute, hour, or day frequency.
Time Needed to Inform All Employees: Tree DFS Pattern
mediumHow 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.
The K Weakest Rows in a Matrix: Binary Search + Sorting
easyHow 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.
Sum of Nodes with Even-Valued Grandparent
mediumHow to solve LeetCode 1315 Sum of Nodes with Even-Valued Grandparent. Tree DFS with grandparent tracking explained with visual diagrams.
Sort the Matrix Diagonally: Diagonal-by-Diagonal Sorting
mediumHow to solve LeetCode 1329 Sort the Matrix Diagonally using diagonal extraction and sorting. Group cells by diagonal index and sort each group independently.
Sort Integers by The Power Value: Collatz Memoization
mediumHow to solve LeetCode 1387 Sort Integers by The Power Value using memoized Collatz sequence computation and custom sorting.
Sort Integers by The Number of 1 Bits: Custom Sort with Bit Counting
easyHow to solve LeetCode 1356 Sort Integers by The Number of 1 Bits using custom sorting with bit counting. Visual walkthrough and Python solution.
Remove Palindromic Subsequences: The Tricky Two-Letter Insight
easyHow to solve LeetCode 1332 Remove Palindromic Subsequences. The answer is always 0, 1, or 2 because the string only contains 'a' and 'b'.
Reduce Array Size to The Half: Greedy Frequency Counting
mediumHow to solve LeetCode 1338 Reduce Array Size to The Half with hash maps and greedy selection. Visual walkthrough of the frequency-based approach.
Rank Transform of an Array: Sort and Map
easyHow 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.
Rank Teams by Votes: Positional Sorting Pattern
mediumHow to solve LeetCode 1366 Rank Teams by Votes using positional vote counting and custom sorting. Step-by-step visual walkthrough with complexity analysis.
Product of the Last K Numbers: Prefix Products with Zero Reset
mediumHow to solve LeetCode 1352 Product of the Last K Numbers. Use a prefix product array with zero-reset to support O(1) product queries.
Number of Times Binary String Is Prefix-Aligned: Max Tracking Pattern
mediumHow to solve LeetCode 1375 Number of Times Binary String Is Prefix-Aligned using running maximum tracking. The prefix alignment pattern explained with visual walkthroughs.
Number of Substrings Containing All Three Characters: Sliding Window
mediumHow to solve LeetCode 1358 Number of Substrings Containing All Three Characters using a sliding window approach. Visual walkthrough and Python solution.
Number of Sub-arrays of Size K and Average >= Threshold
mediumHow to solve LeetCode 1343. Use a fixed-size sliding window to count sub-arrays whose average meets a threshold in O(n) time.
Number of Steps to Reduce a Number to Zero: Simulation and Bit Tricks
easyHow 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.
Number of Operations to Make Network Connected
mediumHow to solve LeetCode 1319 Number of Operations to Make Network Connected. Union-Find for graph connectivity explained with visual diagrams.
Number of Days Between Two Dates: Date-to-Day Conversion
easyHow 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.
Minimum Number of Taps to Open to Water a Garden: Greedy Interval Covering
hardHow 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.
Minimum Number of Steps to Make Two Strings Anagram
mediumHow to solve LeetCode 1347 Minimum Number of Steps to Make Two Strings Anagram. Use character frequency counting to find the minimum replacements needed.
Minimum Flips to Make a OR b Equal to c
mediumHow to solve LeetCode 1318 Minimum Flips to Make a OR b Equal to c. Bit manipulation explained with visual diagrams.
Minimum Distance to Type a Word Using Two Fingers: DP on Finger State
hardHow 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.
Minimum Difficulty of a Job Schedule: DP with Day Partitions
hardHow to solve LeetCode 1335 Minimum Difficulty of a Job Schedule with dynamic programming. Visual walkthrough of the day-partition DP approach.
Minimum Cost to Make at Least One Valid Path in a Grid: 0-1 BFS Pattern
hardHow 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.
Maximum Sum BST in Binary Tree: Post-Order Validation
hardHow 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.
Maximum Students Taking Exam: Bitmask DP on Rows
hardHow to solve LeetCode 1349 Maximum Students Taking Exam. Use bitmask dynamic programming to find the maximum students that can sit without cheating.
Maximum Product of Splitted Binary Tree: Subtree Sum DFS
mediumHow to solve LeetCode 1339 Maximum Product of Splitted Binary Tree. Visual walkthrough of the two-pass DFS approach to maximize edge-cut products.
Maximum Performance of a Team: Sort + Min-Heap
hardHow to solve LeetCode 1383 Maximum Performance of a Team using greedy sorting and a min-heap.
Maximum Number of Events That Can Be Attended: Greedy Heap Pattern
mediumHow 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.
Maximum 69 Number: Greedy Digit Replacement
easyHow to solve LeetCode 1323 Maximum 69 Number using a greedy approach. Find the first 6 and change it to 9 for the maximum value.
Matrix Block Sum
mediumHow to solve LeetCode 1314 Matrix Block Sum. Prefix sum over a 2D matrix explained with visual diagrams.
Lucky Numbers in a Matrix: Row Min Meets Column Max
easyHow 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.
Longest ZigZag Path in a Binary Tree: DFS Direction Tracking
mediumHow to solve LeetCode 1372 Longest ZigZag Path in a Binary Tree using DFS with direction tracking. The zigzag path pattern explained with visual walkthroughs.
Linked List in Binary Tree: Subpath Matching with DFS
mediumHow to solve LeetCode 1367 by combining two DFS functions to check if a linked list matches any downward path in a binary tree.
Largest Multiple of Three: Greedy Digit-Sum Modular Arithmetic
hardHow 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.
Jump Game V: DP on Sorted Values
hardHow to solve LeetCode 1340 Jump Game V with dynamic programming and sorted processing. Visual walkthrough of the value-sorted DP approach.
Jump Game IV: BFS with Same-Value Jumps
hardHow 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.
Increasing Decreasing String: Zigzag Character Picking
easyHow to solve LeetCode 1370 Increasing Decreasing String by counting character frequencies and sweeping the alphabet forward and backward to build a zigzag result.
How Many Numbers Are Smaller Than the Current Number: Sorting and Counting Pattern
easyHow 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.
Generate a String With Characters That Have Odd Counts: Parity Trick
easyHow 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.
Frog Position After T Seconds: BFS with Probability Tracking
hardHow to solve LeetCode 1377 Frog Position After T Seconds using BFS with probability propagation. Tree traversal and probability splitting explained with visual walkthroughs.
Find the Longest Substring Containing Vowels in Even Counts: Bitmask + HashMap Pattern
mediumHow 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.
Find the Distance Value Between Two Arrays: Binary Search Approach
easyHow to solve LeetCode 1385 Find the Distance Value Between Two Arrays using sorting and binary search.
Find the City With the Smallest Number of Neighbors at a Threshold Distance
mediumHow to solve LeetCode 1334 using Floyd-Warshall shortest paths. Compute all-pairs shortest paths, then count reachable cities within the distance threshold.
Find a Corresponding Node of a Binary Tree in a Clone of That Tree
easyHow to solve LeetCode 1379 by traversing both trees simultaneously. The parallel DFS pattern explained with visual walkthroughs.
Filter Restaurants by Vegan-Friendly, Price and Distance
mediumHow 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.
Design a Stack With Increment Operation: Lazy Propagation Pattern
mediumHow to solve LeetCode 1381 Design a Stack With Increment Operation using a lazy increment array. The deferred computation pattern explained with visual walkthroughs.
Delete Leaves With a Given Value: Recursive Tree Pruning
mediumHow to solve LeetCode 1325 Delete Leaves With a Given Value using post-order traversal. Recursive tree pruning explained with visual walkthroughs.
Count Negative Numbers in a Sorted Matrix
easyHow to solve LeetCode 1351 Count Negative Numbers in a Sorted Matrix. Use the staircase traversal pattern to count negatives in O(m + n) time.
Count All Valid Pickup and Delivery Options: Combinatorial Counting Pattern
hardHow 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.
Convert Integer to the Sum of Two No-Zero Integers
easyHow to solve LeetCode 1317 Convert Integer to the Sum of Two No-Zero Integers. A simple math problem explained with visual diagrams.
Construct Target Array With Multiple Sums: Reverse Simulation with Max-Heap
hardHow to solve LeetCode 1354 Construct Target Array With Multiple Sums using reverse simulation with a max-heap. Visual walkthrough and Python solution.
Closest Divisors: Factor Pairs Nearest the Square Root
mediumHow to solve LeetCode 1362 Closest Divisors. The factor pair closest to the square root always has the smallest difference.
Cinema Seat Allocation: Greedy Group Placement
mediumHow to solve LeetCode 1386 Cinema Seat Allocation using bitmask or set-based greedy checking of group placements.
Check If N and Its Double Exist: Hash Set Lookup
easyHow 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.
Break a Palindrome: Greedy Character Replacement
mediumHow to solve LeetCode 1328 Break a Palindrome using greedy character replacement. Find the lexicographically smallest non-palindrome with one change.
Balance a Binary Search Tree: Inorder + Rebuild
mediumHow to solve LeetCode 1382 Balance a Binary Search Tree using inorder traversal and divide-and-conquer rebuild.
Apply Discount Every n Orders: Design with Hash Map
mediumHow 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.
Angle Between Hands of a Clock: Simple Math
mediumHow to solve LeetCode 1344 Angle Between Hands of a Clock. Calculate the positions of both hands and find the smaller angle between them.
XOR Queries of a Subarray: Prefix XOR Pattern
mediumHow to solve LeetCode 1310 XOR Queries of a Subarray using prefix XOR. The prefix computation pattern explained with visual walkthroughs.
Unique Number of Occurrences: Hash Map Frequency Counting
easyHow to solve LeetCode 1207 Unique Number of Occurrences using a hash map and a set. Count frequencies and check uniqueness in one clean pass.
Ugly Number III: Binary Search and Inclusion-Exclusion
mediumHow 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.
Sum of Mutated Array Closest to Target: Binary Search on Answer
mediumHow 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.
Subtract the Product and Sum of Digits of an Integer
easyHow 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.
Split a String in Balanced Strings: Greedy Balance Counter
easyHow to solve LeetCode 1221 Split a String in Balanced Strings using a greedy approach. The balance counter pattern explained with visual walkthroughs.
Sort Items by Groups Respecting Dependencies: Double Topological Sort
hardHow to solve LeetCode 1203 Sort Items by Groups Respecting Dependencies using two-level topological sorting. A hard graph problem broken into manageable pieces.
Smallest String With Swaps: Union-Find for Connected Components
mediumHow to solve LeetCode 1202 Smallest String With Swaps using Union-Find. Group indices by connectivity, sort within groups, and build the smallest string.
Shortest Path in a Grid with Obstacles Elimination: BFS with State
hardHow 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.
Shift 2D Grid: Flatten, Rotate, Reshape
easyHow to solve LeetCode 1260 Shift 2D Grid using the flatten-rotate-reshape pattern. A simulation problem explained with visual walkthroughs.
Sequential Digits: Generating Numbers with Consecutive Digits
mediumHow 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.
Search Suggestions System: Trie Meets Binary Search
mediumHow to solve LeetCode 1268 Search Suggestions System using sorting with binary search or a trie. Visual walkthrough of prefix matching.
Replace the Substring for Balanced String: Sliding Window Pattern
mediumHow to solve LeetCode 1234 Replace the Substring for Balanced String using sliding window. The minimum window pattern explained with visual walkthroughs.
Replace Elements with Greatest Element on Right Side: Right-to-Left Scan
easyHow to solve LeetCode 1299 Replace Elements with Greatest Element on Right Side using a right-to-left scan with running maximum.
Remove Sub-Folders from the Filesystem: Sort and Prefix Check
mediumHow to solve LeetCode 1233 Remove Sub-Folders from the Filesystem using sorting and prefix checking. The pattern explained with visual walkthroughs.
Remove Covered Intervals: Sort and Count
mediumHow 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.
Remove All Adjacent Duplicates in String II: Stack-Based Character Counting
mediumHow to solve LeetCode 1209 Remove All Adjacent Duplicates in String II using a stack with character counts.
Queens That Can Attack the King: Direction Scanning
mediumHow 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.
Path with Maximum Gold: Backtracking on a Grid
mediumHow to solve LeetCode 1219 Path with Maximum Gold using backtracking. The grid DFS pattern explained with visual walkthroughs.
Palindrome Partitioning III: Minimum Changes to Split into K Palindromes
hardHow to solve LeetCode 1278 Palindrome Partitioning III with dynamic programming. Visual walkthrough of the two-layer DP approach.
Number of Ways to Stay in the Same Place After Some Steps
hardHow to solve LeetCode 1269 with dynamic programming. Visual DP table walkthrough for counting paths that return to index 0.
Number of Closed Islands: DFS Boundary Elimination
mediumHow to solve LeetCode 1254 Number of Closed Islands using DFS boundary elimination. A grid traversal pattern explained with visual walkthroughs.
Minimum Remove to Make Valid Parentheses: Stack Index Pattern
mediumHow to solve LeetCode 1249 Minimum Remove to Make Valid Parentheses using a stack to track unmatched indices.
Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
hardHow 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.
Minimum Moves to Reach Target with Rotations: BFS on State Space
hardHow to solve LeetCode 1210 Minimum Moves to Reach Target with Rotations using BFS with (row, col, orientation) states.
Minimum Insertion Steps to Make a String Palindrome
hardHow to solve LeetCode 1312 Minimum Insertion Steps to Make a String Palindrome using dynamic programming. The longest palindromic subsequence approach explained with visual walkthroughs.
Minimum Falling Path Sum II: Multi-Column DP
hardHow 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.
Minimum Cost to Move Chips: The Parity Trick
easyHow to solve LeetCode 1217 Minimum Cost to Move Chips to The Same Position by counting odd and even positions.
Minimum Absolute Difference: Sorting and Adjacent Pairs
easyHow to solve LeetCode 1200 Minimum Absolute Difference using sorting and a single pass. The adjacent-pair pattern explained with visual walkthroughs.
Maximum Score Words Formed by Letters: Backtracking with Letter Budgets
hardHow to solve LeetCode 1255 Maximum Score Words Formed by Letters using backtracking with frequency counting. A subset exploration pattern explained with visual walkthroughs.
Maximum Profit in Job Scheduling: DP with Binary Search
hardHow to solve LeetCode 1235 Maximum Profit in Job Scheduling using dynamic programming with binary search. The weighted interval scheduling pattern explained with visuals.
Maximum Number of Occurrences of a Substring: Sliding Window with Frequency Map
mediumHow to solve LeetCode 1297 Maximum Number of Occurrences of a Substring using sliding window and hash map counting.
Maximum Length of Concatenated String: Backtracking with Bitmasks
mediumHow to solve LeetCode 1239 Maximum Length of a Concatenated String with Unique Characters using backtracking and bitmask character sets.
Maximum Candies You Can Get from Boxes: BFS Simulation
hardHow to solve LeetCode 1298 Maximum Candies You Can Get from Boxes using BFS simulation with key and box tracking.
Longest Arithmetic Subsequence of Given Difference: Hash Map DP
mediumHow to solve LeetCode 1218 Longest Arithmetic Subsequence of Given Difference using dynamic programming with a hash map.
Jump Game III: BFS Reachability Check
mediumHow 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.
Iterator for Combination: Design Meets Backtracking
mediumHow 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.
Group the People Given the Group Size They Belong To: Hash Map Bucketing
mediumHow 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.
Greatest Sum Divisible by Three: Remainder DP Pattern
mediumHow to solve LeetCode 1262 Greatest Sum Divisible by Three using dynamic programming with remainder tracking. A modular arithmetic DP pattern explained with visual walkthroughs.
Get Watched Videos by Your Friends: BFS + Frequency Counting
mediumHow 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.
Get Equal Substrings Within Budget: Sliding Window Cost Control
mediumHow to solve LeetCode 1208 Get Equal Substrings Within Budget using a sliding window over character costs.
Find Winner on a Tic Tac Toe Game: Simulation Made Simple
easyHow 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.
Find the Smallest Divisor Given a Threshold
mediumHow 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.
Find Positive Integer Solution: Two-Pointer Search Pattern
mediumHow to solve LeetCode 1237 Find Positive Integer Solution for a Given Equation using two pointers on a monotonic function.
Find Numbers with Even Number of Digits: Digit Counting
easyHow to solve LeetCode 1295 Find Numbers with Even Number of Digits using digit counting. A clean array filtering approach.
Find N Unique Integers Sum up to Zero: Symmetric Pairs
easyHow to solve LeetCode 1304 Find N Unique Integers Sum up to Zero using symmetric pair generation. A clean math-based approach.
Find Elements in a Contaminated Binary Tree: DFS Recovery with Hash Set
mediumHow 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.
Divide Array in Sets of K Consecutive Numbers: Greedy Grouping
mediumHow to solve LeetCode 1296 Divide Array in Sets of K Consecutive Numbers using greedy grouping with a frequency map.
Dice Roll Simulation: Constrained DP
hardHow to solve LeetCode 1223 Dice Roll Simulation using dynamic programming with consecutive count tracking. The constrained state DP pattern explained with visual walkthroughs.
Deepest Leaves Sum: BFS Level-by-Level Traversal
mediumHow to solve LeetCode 1302 Deepest Leaves Sum using BFS level-order traversal. Track the last level and sum its values.
Decrypt String from Alphabet to Integer Mapping
easyHow to solve LeetCode 1309 Decrypt String from Alphabet to Integer Mapping. A clean string parsing approach explained with visual diagrams.
Decompress Run-Length Encoded List
easyHow to solve LeetCode 1313 Decompress Run-Length Encoded List. A simple array iteration pattern explained with visual diagrams.
Count Vowels Permutation: State Machine DP
hardHow to solve LeetCode 1220 Count Vowels Permutation using dynamic programming with state transitions. The vowel transition pattern explained with visual walkthroughs.
Count Square Submatrices with All Ones: DP on a Grid
mediumHow to solve LeetCode 1277 Count Square Submatrices with All Ones using dynamic programming. Visual grid walkthrough of the min-of-neighbors pattern.
Count Number of Nice Subarrays: Prefix Count Pattern
mediumHow 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.
Convert Binary Number in a Linked List to Integer
easyHow 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.
Check If It Is a Straight Line: Cross Multiplication Pattern
easyHow to solve LeetCode 1232 Check If It Is a Straight Line using cross multiplication to avoid division. The collinearity check explained with visuals.
Cells with Odd Values in a Matrix: Row and Column Parity
easyHow to solve LeetCode 1252 Cells with Odd Values in a Matrix by counting row and column increment parities instead of simulating.
All Elements in Two Binary Search Trees: Inorder Merge
mediumHow 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.
Airplane Seat Assignment Probability: Mathematical Insight
mediumHow to solve LeetCode 1227 Airplane Seat Assignment Probability using mathematical reasoning. The probability pattern explained with visual walkthroughs.
Stone Game II: Minimax Dynamic Programming
mediumHow to solve LeetCode 1140 Stone Game II using suffix sums and memoized recursion. Visual walkthrough of the (index, M) state space with Python solution.
Statistics from a Large Sample: Frequency Array Analysis
mediumHow to solve LeetCode 1093 Statistics from a Large Sample using frequency counting. Compute min, max, mean, median, and mode from a count array.
Snapshot Array: Versioned Data with Binary Search
mediumHow to solve LeetCode 1146 Snapshot Array using hash maps and binary search. Build a versioned array that supports efficient snapshots.
Smallest Sufficient Team: Bitmask DP Pattern
hardHow to solve LeetCode 1125 Smallest Sufficient Team using bitmask dynamic programming. Track skill coverage with bits and find the minimum team.
Smallest Subsequence of Distinct Characters: Monotonic Stack Pattern
mediumHow to solve LeetCode 1081 Smallest Subsequence of Distinct Characters using a monotonic stack with greedy removal. Visual walkthrough and clean Python code.
Shortest Path with Alternating Colors: Modified BFS Pattern
mediumHow to solve LeetCode 1129 Shortest Path with Alternating Colors using BFS with state tracking. Learn the constrained BFS pattern for graph problems.
Shortest Path in Binary Matrix: 8-Directional BFS
mediumHow to solve LeetCode 1091 Shortest Path in Binary Matrix using BFS with 8-directional movement. Visual walkthrough and clean Python code.
Shortest Common Supersequence: LCS-Based String Construction
hardHow to solve LeetCode 1092 Shortest Common Supersequence using LCS dynamic programming with backtracking. Visual walkthrough and clean Python code.
Reverse Substrings Between Each Pair of Parentheses: Inside-Out Stack Pattern
mediumHow 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.
Relative Sort Array: Custom Ordering with Counting
easyHow to solve LeetCode 1122 Relative Sort Array using counting sort and hash maps. Sort one array based on the ordering defined by another.
Print in Order: Thread Synchronization with Barriers
easyHow to solve LeetCode 1114 Print in Order using threading barriers and events. Learn thread synchronization patterns for coding interviews.
Prime Arrangements: Counting Permutations of Primes and Composites
easyHow to solve LeetCode 1175 Prime Arrangements by counting primes up to n and multiplying factorials of prime and non-prime counts.
Previous Permutation With One Swap: Greedy Array Strategy
mediumHow 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.
Path In Zigzag Labelled Binary Tree: Mirror Math
mediumHow 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.
Occurrences After Bigram: Linear Scan Pattern
easyHow to solve LeetCode 1078 Occurrences After Bigram with a simple linear scan. String matching with sliding window of words explained visually.
Number of Valid Words for Each Puzzle: Bitmask Subset Enumeration
hardHow to solve LeetCode 1178 Number of Valid Words for Each Puzzle using bitmask representation and subset enumeration to efficiently match words to puzzles.
Number of Submatrices That Sum to Target: 2D Prefix Sums
hardHow to solve LeetCode 1074 Number of Submatrices That Sum to Target using prefix sums and hash maps. The 2D subarray sum pattern explained visually.
Number of Equivalent Domino Pairs: Counting with Normalization
easyHow to solve LeetCode 1128 Number of Equivalent Domino Pairs using hash map counting with key normalization. A clean pattern for equivalence problems.
Number of Dice Rolls With Target Sum: DP on Dice
mediumHow 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.
N-th Tribonacci Number: Dynamic Programming Fundamentals
easyHow 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.
Minimum Cost Tree From Leaf Values: Monotonic Stack Pattern
mediumHow to solve LeetCode 1130 Minimum Cost Tree From Leaf Values using a monotonic stack. Reduce tree construction to a greedy pairing problem.
Maximum of Absolute Value Expression: Sign Expansion Pattern
mediumHow to solve LeetCode 1131 Maximum of Absolute Value Expression by expanding absolute values into sign combinations. A clean math optimization trick.
Maximum Number of Balloons: Hash Map Frequency Counting
easyHow 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.
Maximum Nesting Depth of Two Valid Parentheses Strings: Depth-Based Splitting
mediumHow 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.
Maximum Level Sum of a Binary Tree: Level-Order BFS Pattern
mediumHow to solve LeetCode 1161 Maximum Level Sum of a Binary Tree using level-order BFS. Track per-level sums with visual walkthroughs.
Lowest Common Ancestor of Deepest Leaves: Recursive Depth Comparison
mediumHow to solve LeetCode 1123 Lowest Common Ancestor of Deepest Leaves using recursive DFS. Find the LCA by comparing subtree depths.
Longest Well-Performing Interval: Prefix Sum with Hash Map
mediumHow 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.
Longest Chunked Palindrome Decomposition: Greedy Matching
hardHow to solve LeetCode 1147 Longest Chunked Palindrome Decomposition using greedy two-pointer matching. Break a string into the maximum number of palindromic chunks.
Letter Tile Possibilities: Counting with Backtracking
mediumHow to solve LeetCode 1079 Letter Tile Possibilities using backtracking with frequency counting. Generate all unique non-empty sequences explained visually.
Last Substring in Lexicographical Order: Two-Pointer Suffix Comparison
hardHow to solve LeetCode 1163 Last Substring in Lexicographical Order using a two-pointer approach. Find the lexicographically largest suffix in O(n) time.
Largest Values From Labels: Greedy Selection with Constraints
mediumHow to solve LeetCode 1090 Largest Values From Labels using greedy sorting with label frequency limits. Visual walkthrough and clean Python code.
Largest 1-Bordered Square: Prefix Sum on a Grid
mediumHow to solve LeetCode 1139 Largest 1-Bordered Square by precomputing horizontal and vertical consecutive-ones counts and verifying square borders efficiently.
K-Concatenation Maximum Sum: Extending Kadane's to Repeated Arrays
mediumHow to solve LeetCode 1191 K-Concatenation Maximum Sum using Kadane's algorithm with prefix and suffix sums. Handle repeated arrays in O(n) time.
Invalid Transactions: Hash Map Grouping Pattern
mediumHow to solve LeetCode 1169 Invalid Transactions using hash map grouping and pairwise comparison. Parse, group, and validate transactions with visual walkthroughs.
Insufficient Nodes in Root to Leaf Paths: Tree Pruning with DFS
mediumHow to solve LeetCode 1080 Insufficient Nodes in Root to Leaf Paths using recursive DFS. Tree pruning pattern explained with visual diagrams.
Grumpy Bookstore Owner: Sliding Window Technique
mediumHow to solve LeetCode 1052 Grumpy Bookstore Owner using the sliding window pattern. Maximize customer satisfaction by choosing the optimal window.
Greatest Common Divisor of Strings: GCD Pattern
easyHow to solve LeetCode 1071 Greatest Common Divisor of Strings using the GCD pattern. Find the largest string that divides both input strings.
Flip Columns For Maximum Number of Equal Rows: Pattern Matching in Matrices
mediumHow 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.
Find Words That Can Be Formed by Characters: Character Frequency Pattern
easyHow to solve LeetCode 1160 Find Words That Can Be Formed by Characters using character frequency counting. Hash map counting pattern explained with visual walkthroughs.
Find in Mountain Array: Triple Binary Search
hardHow to solve LeetCode 1095 Find in Mountain Array using three binary searches. Find the peak, then search ascending and descending halves.
Filling Bookcase Shelves: Minimizing Height with DP
mediumHow to solve LeetCode 1105 Filling Bookcase Shelves using dynamic programming. Visual shelf-packing walkthrough and clean Python solution.
Duplicate Zeros: In-Place Array Shifting
easyHow to solve LeetCode 1089 Duplicate Zeros by shifting elements in-place from right to left. Visual walkthrough and clean Python code.
Distribute Candies to People: Round-Robin Simulation
easyHow to solve LeetCode 1103 Distribute Candies to People using simulation. Distribute increasing amounts in a round-robin pattern.
Distant Barcodes: Frequency-Based Greedy Rearrangement
mediumHow to solve LeetCode 1054 Distant Barcodes using frequency counting and greedy placement. Rearrange elements so no two adjacent are equal.
Distance Between Bus Stops: Circular Array Minimum Path
easyHow to solve LeetCode 1184 Distance Between Bus Stops by computing clockwise distance and taking the minimum of both directions around the circular route.
Delete Nodes And Return Forest: Splitting a Tree with Post-Order DFS
mediumHow 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.
Defanging an IP Address: Simple String Replacement
easyHow to solve LeetCode 1108 Defanging an IP Address by replacing dots with [.]. Visual walkthrough with Python code and complexity analysis.
Decrease Elements To Make Array Zigzag: Greedy Two-Pass Strategy
mediumHow 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.
Day of the Year: Date Parsing and Leap Year Logic
easyHow to solve LeetCode 1154 Day of the Year using date parsing and prefix sums of month lengths. Handle leap years correctly.
Day of the Week: Zeller's Congruence in Code
easyHow 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.
Critical Connections in a Network: Tarjan's Bridge-Finding Algorithm
hardHow 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.
Corporate Flight Bookings: Difference Array for Range Updates
mediumHow to solve LeetCode 1109 Corporate Flight Bookings using a difference array and prefix sum. Efficiently apply range updates to compute total seats per flight.
Compare Strings by Frequency of the Smallest Character: Binary Search on Sorted Counts
mediumHow to solve LeetCode 1170 Compare Strings by Frequency of the Smallest Character using sorted frequency arrays and binary search.
Car Pooling: Difference Array Sweep Line
mediumHow to solve LeetCode 1094 Car Pooling using a difference array and sweep line. Track passenger counts at each stop efficiently.
Can Make Palindrome from Substring: Prefix XOR for Character Parity
mediumHow to solve LeetCode 1177 Can Make Palindrome from Substring using prefix XOR bitmasks to count odd-frequency characters in any substring in O(1).
Brace Expansion II: Recursive Set Operations
hardHow to solve LeetCode 1096 Brace Expansion II using a stack-based parser with union and concatenation of string sets.
Binary Tree Coloring Game: Counting Subtree Sizes
mediumHow to solve LeetCode 1145 Binary Tree Coloring Game using subtree counting. Determine if player 2 can always win by choosing the right adjacent node.
As Far from Land as Possible: Multi-Source BFS Pattern
mediumHow 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.
Alphabet Board Path: Grid Coordinate Navigation
mediumHow to solve LeetCode 1138 Alphabet Board Path using coordinate mapping and careful handling of the letter 'z'. The grid navigation pattern explained.
Adding Two Negabinary Numbers: Base -2 Arithmetic
mediumHow to solve LeetCode 1073 Adding Two Negabinary Numbers. Learn base -2 addition with carry handling, explained with visual diagrams.
Video Stitching: Greedy Interval Coverage Pattern
mediumHow to solve LeetCode 1024 Video Stitching using a greedy interval approach. Cover a target range [0, time] with the minimum number of clips.
Valid Boomerang: Cross Product for Collinearity
easyHow 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.
Uncrossed Lines: LCS in Disguise
mediumHow to solve LeetCode 1035 Uncrossed Lines with 2D DP. This problem is the Longest Common Subsequence pattern applied to two integer arrays.
Two City Scheduling: Greedy Cost Optimization
mediumHow 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.
Sum of Root To Leaf Binary Numbers: Tree DFS Pattern
easyHow to solve LeetCode 1022 Sum of Root To Leaf Binary Numbers using DFS with bit manipulation. Build binary numbers along root-to-leaf paths.
Sum of Root To Leaf Binary Numbers: DFS Binary Accumulation
easyHow 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.
Subarrays with K Different Integers: The At-Most Trick
hardHow to solve LeetCode 992 Subarrays with K Different Integers. Use the at-most sliding window technique to count subarrays with exactly k distinct values.
Stream of Characters: Reverse Trie for Suffix Matching
hardHow to solve LeetCode 1032 Stream of Characters using a reverse trie. Insert words backwards and search from the end of the stream buffer.
Smallest Integer Divisible by K: Remainder Cycle Detection
mediumHow to solve LeetCode 1015 Smallest Integer Divisible by K using modular arithmetic and cycle detection. The remainder tracking pattern explained with visual walkthroughs.
Satisfiability of Equality Equations: Union-Find for Variable Constraints
mediumHow to solve LeetCode 990 Satisfiability of Equality Equations. Use union-find to group equal variables, then check inequality constraints for contradictions.
Rotting Oranges: Multi-Source BFS Pattern
mediumHow to solve LeetCode 994 Rotting Oranges using multi-source BFS. The grid BFS pattern explained with visual walkthroughs.
Robot Bounded In Circle: Simulation and Direction Vectors
mediumHow to solve LeetCode 1041 Robot Bounded In Circle using direction simulation. The direction vector pattern explained with visual walkthroughs.
Remove Outermost Parentheses: Depth Counter Pattern
easyHow to solve LeetCode 1021 Remove Outermost Parentheses using a depth counter. A clean pattern for identifying nesting levels in parentheses strings.
Remove All Adjacent Duplicates In String: Stack Pattern
easyHow to solve LeetCode 1047 Remove All Adjacent Duplicates In String using a stack. The stack-based duplicate removal pattern explained with visual walkthroughs.
Recover a Tree From Preorder Traversal: Stack-Based Tree Construction
hardHow to solve LeetCode 1028 Recover a Tree From Preorder Traversal using a stack. Parse a dash-encoded preorder string to rebuild the binary tree.
Partition Array Into Three Parts With Equal Sum: Greedy Prefix Scan
easyHow to solve LeetCode 1013 Partition Array Into Three Parts With Equal Sum using a greedy prefix sum approach in O(n) time.
Partition Array for Maximum Sum: DP with Partition Choices
mediumHow to solve LeetCode 1043 Partition Array for Maximum Sum using dynamic programming. The partition DP pattern explained with visual walkthroughs.
Pairs of Songs With Total Durations Divisible by 60: Remainder Counting
mediumHow to solve LeetCode 1010 Pairs of Songs With Total Durations Divisible by 60 using a remainder hash map in O(n) time.
Online Stock Span: Monotonic Stack Pattern
mediumHow to solve LeetCode 901 Online Stock Span using a monotonic decreasing stack. Step-by-step visual walkthrough of the span calculation.
Numbers At Most N Given Digit Set: Digit DP Pattern
hardHow to solve LeetCode 902 Numbers At Most N Given Digit Set using digit dynamic programming. Count valid numbers digit by digit with visual walkthrough.
Number of Squareful Arrays: Backtracking with Graph Modeling
hardHow to solve LeetCode 996 Number of Squareful Arrays using backtracking and graph adjacency. Explained with visual walkthroughs.
Number of Enclaves: Border-Connected Flood Fill
mediumHow 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.
Next Greater Node In Linked List: Monotonic Stack on Lists
mediumHow 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.
Moving Stones Until Consecutive II: Sliding Window on Sorted Endpoints
mediumHow to solve LeetCode 1040 Moving Stones Until Consecutive II using sliding window and greedy endpoints. The sorted window pattern explained with visual walkthroughs.
Minimum Score Triangulation of Polygon: Interval DP on Shapes
mediumHow 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.
Minimum Number of K Consecutive Bit Flips: Greedy Sliding Window
hardHow to solve LeetCode 995 Minimum Number of K Consecutive Bit Flips using a greedy approach with a sliding window. Explained with visual walkthroughs.
Minimum Domino Rotations For Equal Row: Greedy Candidate Check
mediumHow to solve LeetCode 1007 Minimum Domino Rotations For Equal Row using a greedy approach. Check candidate values and count minimum swaps.
Minimum Cost to Merge Stones: Interval DP
hardHow 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.
Maximum Sum of Two Non-Overlapping Subarrays: Prefix Sum + Sliding Window
mediumHow 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.
Maximum Difference Between Node and Ancestor: Tree Min/Max Tracking
mediumHow to solve LeetCode 1026 Maximum Difference Between Node and Ancestor using DFS with min/max tracking. Find the largest |ancestor - descendant| difference.
Maximum Binary Tree II: Rightmost Path Insertion
mediumHow to solve LeetCode 998 Maximum Binary Tree II by walking the rightmost path. Tree insertion pattern explained with visual walkthroughs.
Maximize Sum Of Array After K Negations: Greedy Sorting Pattern
easyHow 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.
Max Consecutive Ones III: Sliding Window with Flips
mediumHow to solve LeetCode 1004 Max Consecutive Ones III using the sliding window pattern. Track flipped zeros and maintain the longest window of consecutive ones.
Matrix Cells in Distance Order: BFS Rings on a Grid
easyHow to solve LeetCode 1030 Matrix Cells in Distance Order using BFS or sorting by Manhattan distance. A clean introduction to distance-based grid traversal.
Longest String Chain: Hash Map DP Pattern
mediumHow to solve LeetCode 1048 Longest String Chain using hash map dynamic programming. The word chain DP pattern explained with visual walkthroughs.
Longest Duplicate Substring: Binary Search and Rolling Hash
hardHow 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.
Longest Arithmetic Subsequence: DP with Hash Map Pattern
mediumHow to solve LeetCode 1027 Longest Arithmetic Subsequence using dynamic programming with hash maps. Track the longest subsequence for each common difference.
Last Stone Weight: Max Heap Pattern
easyHow to solve LeetCode 1046 Last Stone Weight using a max heap. Learn the heap-based simulation pattern with visual walkthroughs.
Last Stone Weight II: Subset Sum DP Pattern
mediumHow to solve LeetCode 1049 Last Stone Weight II using subset sum dynamic programming. The partition minimization pattern explained with visual walkthroughs.
Height Checker: Sort and Compare Pattern
easyHow to solve LeetCode 1051 Height Checker using sort and compare. The comparison counting pattern explained with visual walkthroughs.
Grid Illumination: Hash Map Line Counting
hardHow 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.
Flower Planting With No Adjacent: Greedy Graph Coloring
mediumHow to solve LeetCode 1042 Flower Planting With No Adjacent using greedy graph coloring. The constrained coloring pattern explained with visual walkthroughs.
Find the Town Judge: Graph Degree Counting
easyHow to solve LeetCode 997 Find the Town Judge using in-degree and out-degree counting. The trust graph pattern explained.
Find Common Characters: Frequency Intersection
easyHow to solve LeetCode 1002 Find Common Characters using character frequency counting and element-wise minimums. Step-by-step visual walkthrough.
Divisor Game: Math Pattern Recognition
easyHow to solve LeetCode 1025 Divisor Game using mathematical insight. Determine the winner with a simple even/odd check.
Cousins in Binary Tree: Checking Depth and Parent with BFS
easyHow 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.
Convert to Base -2: Negative Base Number Systems
mediumHow to solve LeetCode 1017 Convert to Base -2 using modified division with remainder adjustment. Negative base conversion explained with visual walkthroughs.
Construct BST from Preorder Traversal: Upper Bound Recursion
mediumHow to solve LeetCode 1008 Construct Binary Search Tree from Preorder Traversal using an upper bound recursive approach in O(n) time.
Complement of Base 10 Integer: Bit Flipping with XOR
easyHow to solve LeetCode 1009 Complement of Base 10 Integer using a bitmask and XOR in O(log n) time.
Coloring A Border: DFS Component Boundary Detection
mediumHow to solve LeetCode 1034 Coloring A Border using DFS to find a connected component and identify its border cells. A practical grid traversal exercise.
Clumsy Factorial: Stack-Based Expression Evaluation
mediumHow to solve LeetCode 1006 Clumsy Factorial using a stack to evaluate expressions with rotating operations. Master the operator precedence pattern.
Check If Word Is Valid After Substitutions: Stack Reduction
mediumHow to solve LeetCode 1003 Check If Word Is Valid After Substitutions using a stack. Visual walkthrough with Python code.
Capacity To Ship Packages Within D Days: Binary Search on Answer
mediumHow to solve LeetCode 1011 Capacity To Ship Packages Within D Days using binary search on the answer in O(n log S) time.
Camelcase Matching: Two-Pointer String Pattern
mediumHow to solve LeetCode 1023 Camelcase Matching using two pointers. Match patterns against camelCase strings by skipping lowercase insertions.
Broken Calculator: Working Backwards with Greedy Division
mediumHow to solve LeetCode 991 Broken Calculator. Work backwards from target, dividing even numbers and adding 1 to odd numbers for a greedy solution.
Binary Search Tree to Greater Sum Tree
mediumHow 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.
Binary Prefix Divisible By 5: Running Remainder Pattern
easyHow to solve LeetCode 1018 Binary Prefix Divisible By 5 using running modular arithmetic. The prefix remainder pattern explained with visual walkthroughs.
Best Sightseeing Pair: Decomposing the Score Formula
mediumHow to solve LeetCode 1014 Best Sightseeing Pair by decomposing the score into two independent terms in O(n) time.
Available Captures for Rook: Direct Simulation
easyHow to solve LeetCode 999 Available Captures for Rook by finding the rook and scanning four directions on a chessboard grid.
Add to Array-Form of Integer: Digit-by-Digit Addition with Carry
easyHow 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.
Vowel Spellchecker: Priority-Based Fuzzy Matching
mediumHow to solve LeetCode 966 Vowel Spellchecker. Build three hash maps for exact, case-insensitive, and vowel-insensitive matching in O(n + q) time.
Vertical Order Traversal of a Binary Tree: Coordinate Sorting
hardHow 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.
Verifying an Alien Dictionary: Custom Sort Order Validation
easyHow 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.
Validate Stack Sequences: Greedy Stack Simulation
mediumHow to solve LeetCode 946 Validate Stack Sequences by simulating push and pop operations with a greedy approach. Push elements and eagerly pop whenever possible.
Valid Mountain Array: Linear Scan
easyHow 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.
Univalued Binary Tree: Simple Tree Traversal Check
easyHow to solve LeetCode 965 Univalued Binary Tree. Use DFS to verify every node shares the same value in O(n) time.
Unique Paths III: Walk Every Square Exactly Once
hardHow to solve LeetCode 980 Unique Paths III. Use backtracking to find all paths from start to end that visit every walkable cell exactly once.
Unique Email Addresses: String Normalization
easyHow to solve LeetCode 929 Unique Email Addresses. Normalize email local names by removing dots and ignoring plus suffixes, then count unique addresses.
Triples with Bitwise AND Equal To Zero: Precompute Pairwise Results
hardHow 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).
Time Based Key-Value Store: Binary Search Meets Hash Maps
mediumHow to solve LeetCode 981 Time Based Key-Value Store. Combine a hash map with binary search on sorted timestamps for efficient versioned lookups.
Three Equal Parts: Binary Array Partitioning
hardHow to solve LeetCode 927 Three Equal Parts. Count ones and find partition indices where all three parts represent the same binary value.
Tallest Billboard: DP on Difference Between Two Subsets
hardHow to solve LeetCode 956 Tallest Billboard. Use dynamic programming keyed on the height difference between two supports to find the tallest equal-height partition.
Sum of Even Numbers After Queries: Incremental Even Sum Tracking
mediumHow 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.
Subarray Sums Divisible by K: Prefix Sums Meet Modular Arithmetic
mediumHow 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.
String Without AAA or BBB: Greedy Interleaving
mediumHow 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.
Stamping The Sequence: Reverse Greedy Simulation
hardHow to solve LeetCode 936 Stamping The Sequence. Work backwards from the target, greedily un-stamping matches until the entire string is erased.
Squares of a Sorted Array: Two Pointers from Both Ends
easyHow 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.
Smallest String Starting From Leaf
mediumHow 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.
Shortest Bridge: DFS Plus BFS on a Grid
mediumHow 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.
Reveal Cards In Increasing Order: Reverse Simulation with a Deque
mediumHow to solve LeetCode 950 Reveal Cards In Increasing Order by sorting cards and simulating the reveal process in reverse using a deque.
Reorder Data in Log Files: Custom Sorting
mediumHow 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.
Regions Cut By Slashes: Grid Upscaling with Connected Components
mediumHow to solve LeetCode 959 Regions Cut By Slashes. Upscale the grid to 3x3 cells, mark slashes as walls, and count connected components.
Range Sum of BST: Pruned DFS
easyHow to solve LeetCode 938 Range Sum of BST by leveraging the BST property to prune unnecessary branches during DFS.
Prison Cells After N Days: Cycle Detection in State Space
mediumHow to solve LeetCode 957 Prison Cells After N Days. Detect the cycle in cell states and use modular arithmetic to skip ahead efficiently.
Powerful Integers: Enumerating Sums of Powers
mediumHow 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.
Pancake Sorting: Sorting by Prefix Reversals
mediumHow to solve LeetCode 969 Pancake Sorting. Use a selection sort strategy with prefix reversals to place each element in its correct position.
Odd Even Jump: Monotonic Stack Meets Dynamic Programming
hardHow to solve LeetCode 975 Odd Even Jump. Use a monotonic stack to precompute jump targets and DP to determine which indices reach the end.
Numbers With Same Consecutive Differences: Digit-by-Digit BFS
mediumHow 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.
Number of Recent Calls: Queue-Based Sliding Window
easyHow to solve LeetCode 933 Number of Recent Calls. Use a queue to track timestamps and remove expired entries to count recent pings.
N-Repeated Element in Size 2N Array: Finding the Majority with a Set
easyHow 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.
Most Stones Removed with Same Row or Column: Union-Find Connected Components
mediumHow 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.
Minimum Increment to Make Array Unique: Sort and Bump
mediumHow 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.
Minimum Falling Path Sum: Matrix Dynamic Programming
mediumHow 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.
Minimum Cost For Tickets: Dynamic Programming on a Calendar
mediumHow 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.
Minimum Area Rectangle: Hash Set Geometry
mediumHow 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.
Minimum Area Rectangle II: Diagonal-Based Geometry
mediumHow to solve LeetCode 963 Minimum Area Rectangle II. Group point pairs by diagonal center and length to find the smallest non-axis-aligned rectangle.
Minimize Malware Spread II: Graph Component Analysis
hardHow to solve LeetCode 928 Minimize Malware Spread II using Union-Find. Remove infected nodes completely and find which removal saves the most clean nodes.
Maximum Width Ramp: Stack-Based Optimal Pairs
mediumHow 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.
Longest Turbulent Subarray: Tracking Alternating Comparisons
mediumHow to solve LeetCode 978 Longest Turbulent Subarray. Track increasing and decreasing streak lengths that swap on alternation for an O(n) solution.
Largest Time for Given Digits: Permutation and Validation
mediumHow to solve LeetCode 949 Largest Time for Given Digits by generating all permutations of four digits and validating each as a 24-hour time.
Largest Perimeter Triangle: Greedy Sorting for the Triangle Inequality
easyHow to solve LeetCode 976 Largest Perimeter Triangle. Sort descending and greedily check consecutive triples for the triangle inequality.
Largest Component Size by Common Factor: Union-Find with Prime Factorization
hardHow 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.
Knight Dialer: Dynamic Programming on a Keypad
mediumHow to solve LeetCode 935 Knight Dialer. Use dynamic programming to count the number of distinct phone numbers a chess knight can dial.
K Closest Points to Origin: Heap and Quickselect Solutions
mediumHow 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.
Interval List Intersections: Two-Pointer Merge
mediumHow to solve LeetCode 986 Interval List Intersections with a two-pointer technique. Walk through the approach, Python solution, edge cases, and reusable building blocks.
Flip Equivalent Binary Trees: Recursive Tree Comparison
mediumHow to solve LeetCode 951 Flip Equivalent Binary Trees using recursive comparison. At each node, check if children match directly or after flipping.
Flip Binary Tree To Match Preorder Traversal: Greedy DFS Approach
mediumHow to solve LeetCode 971 Flip Binary Tree To Match Preorder Traversal. Use DFS with greedy child swapping to match a target preorder sequence.
Find the Shortest Superstring: Bitmask DP on Overlaps
hardHow 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.
Distribute Coins in Binary Tree: Counting the Cost of Balance
mediumHow 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.
Distinct Subsequences II: DP with Duplicate Tracking
hardHow 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.
DI String Match: Greedy Two-Pointer Construction
easyHow 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.
Delete Columns to Make Sorted: Column-Wise Validation
easyHow to solve LeetCode 944 Delete Columns to Make Sorted by checking each column for sorted order. A clean column iteration pattern.
Delete Columns to Make Sorted III: Longest Increasing Subsequence on Columns
hardHow to solve LeetCode 960 Delete Columns to Make Sorted III. Apply LIS dynamic programming on columns where each column is compared row-wise.
Delete Columns to Make Sorted II: Greedy Column Selection
mediumHow 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.
Check Completeness of a Binary Tree: BFS Level-Order Validation
mediumHow to solve LeetCode 958 Check Completeness of a Binary Tree. Use BFS to detect gaps in level-order traversal and validate completeness.
Binary Tree Cameras: Minimum Cameras with Greedy DFS
hardHow 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.
Binary Subarrays With Sum: Prefix Sum Counting
mediumHow 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.
Beautiful Array: Divide and Conquer Construction
mediumHow to solve LeetCode 932 Beautiful Array. Use divide and conquer to build an array where no element is the arithmetic mean of two others.
Bag of Tokens: Greedy Two-Pointer Strategy
mediumHow 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.
Array of Doubled Pairs: Greedy Matching with Frequency Maps
mediumHow 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.
X of a Kind in a Deck of Cards: GCD to the Rescue
easyHow 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.
Word Subsets: Merging Character Requirements
mediumHow to solve LeetCode 916 Word Subsets. Merge all subset requirements into one max-frequency map, then filter words in a single pass.
Walking Robot Simulation: Grid Traversal with Obstacle Avoidance
mediumHow to solve LeetCode 874 Walking Robot Simulation using direction vectors and a hash set for obstacles. Visual walkthrough with Python solution.
Uncommon Words from Two Sentences: Hash Map Counting
easyHow to solve LeetCode 884 Uncommon Words from Two Sentences. Visual frequency counting approach with Python.
Transpose Matrix: Row-Column Swap Pattern
easyHow 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.
Surface Area of 3D Shapes: Grid Geometry
easyHow to solve LeetCode 892 Surface Area of 3D Shapes. Count exposed faces by computing each column's contribution and subtracting neighbor overlaps.
Super Palindromes: Enumerating Palindromic Squares
hardHow to solve LeetCode 906 Super Palindromes. Generate palindrome roots, square them, and check if the square is also a palindrome.
Super Egg Drop: Flipping the DP Perspective
hardHow 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'.
Sum of Subsequence Widths: Sorting and Combinatorics
hardHow 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.
Sum of Subarray Minimums: Monotonic Stack Contribution Technique
mediumHow 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.
Stone Game: Game Theory and Dynamic Programming
mediumHow to solve LeetCode 877 Stone Game using mathematical insight and interval DP. Visual walkthrough with Python solution.
Spiral Matrix III: Walking a Spiral from Any Starting Point
mediumHow to solve LeetCode 885 Spiral Matrix III. Visual simulation of spiral traversal with direction cycling and boundary checks.
Sort Array By Parity: Two-Pointer Partition
easyHow to solve LeetCode 905 Sort Array By Parity using a two-pointer swap. Partition even numbers to the front in one pass.
Sort Array By Parity II: Two-Pointer Placement
easyHow 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.
Sort an Array: Merge Sort from Scratch
mediumHow to solve LeetCode 912 Sort an Array. Build merge sort from scratch to understand divide-and-conquer sorting.
Snakes and Ladders: BFS on a Board Game
mediumHow 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.
Smallest Range II: Minimizing the Gap After Adding or Subtracting k
mediumHow 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.
Smallest Range I: Shrink the Gap with Math
easyHow 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.
RLE Iterator: Consuming a Run-Length Encoded Sequence
mediumHow to solve LeetCode 900 RLE Iterator. Use a pointer to walk through the encoded array, consuming counts across multiple next calls.
Reverse Only Letters: Two Pointer Approach for Selective Reversal
easyHow to solve LeetCode 917 Reverse Only Letters. Use two pointers to reverse only alphabetic characters in a string while preserving special character positions.
Reordered Power of 2: Digit Frequency Matching
mediumHow to solve LeetCode 869 Reordered Power of 2 by comparing digit frequencies. Learn why sorting digits creates a canonical form for anagram comparison.
Reachable Nodes in Subdivided Graph: Modified Dijkstra
hardHow to solve LeetCode 882 Reachable Nodes In Subdivided Graph using modified Dijkstra's algorithm with a min-heap. Visual walkthrough with Python solution.
Projection Area of 3D Shapes: Count What You Can See
easyHow to solve LeetCode 883 Projection Area of 3D Shapes. Visual breakdown of top, front, and side projections with a clean Python solution.
Profitable Schemes: 3D Dynamic Programming
hardHow to solve LeetCode 879 Profitable Schemes using 3D DP with space optimization. Visual walkthrough with Python solution.
Possible Bipartition: Graph Two-Coloring with BFS
mediumHow to solve LeetCode 886 Possible Bipartition. Visual graph coloring walkthrough using BFS to check if a bipartite split exists.
Partition Array into Disjoint Intervals: Finding the Split Point
mediumHow 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.
Orderly Queue: When One Move Changes Everything
hardHow 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.
Online Election: Precompute Leaders and Binary Search
mediumHow to solve LeetCode 911 Online Election. Precompute the leading candidate at each vote time, then answer queries in O(log n) with binary search.
Number of Music Playlists: DP with Replay Constraints
hardHow 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.
Nth Magical Number: Binary Search and Inclusion-Exclusion
hardHow to solve LeetCode 878 Nth Magical Number using binary search with the inclusion-exclusion counting formula. Visual walkthrough with Python solution.
Monotonic Array: Single-Pass Flag Check
easyHow to solve LeetCode 896 Monotonic Array by tracking two boolean flags in a single pass through the array.
Minimum Number of Refueling Stops: Greedy with a Max Heap
hardHow 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.
Minimum Add to Make Parentheses Valid: Greedy Balance Counting
mediumHow 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.
Minimize Malware Spread: Union-Find Component Analysis
hardHow to solve LeetCode 924 Minimize Malware Spread. Use Union-Find to identify which infected node removal saves the most nodes from infection.
Middle of the Linked List: The Slow and Fast Pointer Technique
easyHow to solve LeetCode 876 Middle of the Linked List using the tortoise and hare approach. Visual walkthrough with Python solution.
Maximum Sum Circular Subarray: Kadane's Algorithm Extended
mediumHow to solve LeetCode 918 Maximum Sum Circular Subarray. Extend Kadane's algorithm to handle circular arrays by finding both max and min subarrays.
Maximum Frequency Stack: Stack of Stacks by Frequency
hardHow to solve LeetCode 895 Maximum Frequency Stack with a frequency map and group map for O(1) push and pop.
Long Pressed Name: Two-Pointer Character Matching
easyHow 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.
Length of Longest Fibonacci Subsequence: Hash Set + DP
mediumHow to solve LeetCode 873 Length of Longest Fibonacci Subsequence using hash map lookups and dynamic programming. Visual walkthrough with Python solution.
Leaf-Similar Trees: Comparing Leaf Sequences
easyHow to solve LeetCode 872 Leaf-Similar Trees by collecting leaf sequences with DFS. Visual walkthrough with Python solution.
Increasing Order Search Tree: Flatten a BST with Inorder Traversal
easyHow to solve LeetCode 897 Increasing Order Search Tree by using inorder traversal to rearrange a BST into a right-only chain.
Groups of Special-Equivalent Strings: Canonical Key Grouping
mediumHow to solve LeetCode 893 Groups of Special-Equivalent Strings using sorted even/odd index keys and a hash map.
Fruit Into Baskets: Sliding Window with Two Fruit Types
mediumHow 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.
Flip String to Monotone Increasing: Prefix Counting
mediumHow 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.
Find and Replace Pattern: Bijection Mapping
mediumHow to solve LeetCode 890 Find and Replace Pattern. Use two hash maps to verify a bijection between pattern and word characters.
Fair Candy Swap: Hash Set Lookup
easyHow to solve LeetCode 888 Fair Candy Swap. Use a hash set to find the pair that equalizes totals in O(n) time.
Decoded String at Index: Reverse Traversal Without Building the String
mediumHow to solve LeetCode 880 Decoded String at Index using reverse traversal. Find the k-th character of a decoded string without constructing it.
Construct Binary Tree from Preorder and Postorder: Recursive Partitioning
mediumHow to solve LeetCode 889 Construct Binary Tree from Preorder and Postorder Traversal. Use recursive partitioning to rebuild the tree in O(n) time.
Complete Binary Tree Inserter: BFS Queue Design
mediumHow 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.
Cat and Mouse: Game Theory on Graphs
hardHow 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.
Boats to Save People: Greedy Two Pointers
mediumHow to solve LeetCode 881 Boats to Save People using sorting and a greedy two-pointer approach. Visual walkthrough with Python solution.
Bitwise ORs of Subarrays: Tracking Distinct OR Values Efficiently
mediumHow to solve LeetCode 898 Bitwise ORs of Subarrays. Track reachable OR values at each position using set propagation to count distinct results.
Binary Gap: Finding the Longest Distance Between 1-Bits
easyHow to solve LeetCode 868 Binary Gap by scanning bit positions. Learn the pattern of tracking previous occurrences while iterating through binary representations.
All Possible Full Binary Trees: Recursive Construction with Memoization
mediumHow to solve LeetCode 894 by recursively splitting nodes into left and right subtrees and caching results for each odd n.
Advantage Shuffle: Greedy Matching with Sorted Arrays
mediumHow 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.
3Sum With Multiplicity: Counting Combinations
mediumHow 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.
Unique Morse Code Words: Hash Set Deduplication
easyHow to solve LeetCode 804 Unique Morse Code Words by converting each word to its Morse code representation and counting unique transformations with a set.
Sum of Distances in Tree: Re-rooting Technique
hardHow 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).
Subdomain Visit Count: Hash Map Aggregation
mediumHow to solve LeetCode 811 Subdomain Visit Count by splitting domains into subdomains and aggregating visit counts with a hash map.
Split Array into Fibonacci Sequence: Backtracking with Pruning
mediumHow to solve LeetCode 842 Split Array into Fibonacci Sequence using backtracking. Leading-zero handling, integer overflow checks, and pruning explained visually.
Soup Servings: Probability with Memoized Recursion
mediumHow to solve LeetCode 808 Soup Servings using memoized recursion to compute the probability that soup A empties first, with Python code and visual walkthrough.
Smallest Subtree with all the Deepest Nodes: Bottom-Up Depth Comparison
mediumHow 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.
Similar String Groups: Union-Find Explained
hardHow to solve LeetCode 839 Similar String Groups using Union-Find. Visual walkthrough of grouping anagram strings by swap similarity.
Shortest Subarray with Sum at Least K: Prefix Sums Meet a Monotonic Deque
hardHow 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.
Shortest Path Visiting All Nodes: BFS with Bitmask
hardHow to solve LeetCode 847 Shortest Path Visiting All Nodes using BFS with bitmask state tracking. Visit every node in the minimum number of steps.
Shortest Path to Get All Keys: BFS with Bitmask State
hardHow 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.
Shortest Distance to a Character: Two-Pass Array Sweep
easyHow to solve LeetCode 821 Shortest Distance to a Character using two passes over the array. Visual walkthrough of bidirectional distance computation.
Short Encoding of Words: Suffix Deduplication with Tries
mediumHow to solve LeetCode 820 Short Encoding of Words by removing suffix duplicates using a trie or set-based approach. Visual walkthrough of suffix matching.
Shifting Letters: Suffix Sum for Character Shifts
mediumHow to solve LeetCode 848 Shifting Letters with a suffix sum approach. Accumulate shifts from right to left and apply modular arithmetic.
Score of Parentheses: Stack-Based Scoring of Nested Brackets
mediumHow to solve LeetCode 856 Score of Parentheses. Use a stack to track nesting depth and compute scores for balanced parentheses strings.
Score After Flipping Matrix: Greedy Bit Maximization
mediumHow 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.
Rectangle Overlap: Axis Projection Check
easyHow to solve LeetCode 836 Rectangle Overlap. Check if two rectangles overlap by testing axis projections independently.
Push Dominoes: Force Simulation Explained
mediumHow to solve LeetCode 838 Push Dominoes using force simulation. Visual walkthrough of the two-pass approach.
Positions of Large Groups: Linear Scan Grouping
easyHow to solve LeetCode 830 Positions of Large Groups by scanning for runs of identical characters. Visual walkthrough of the linear grouping approach.
Peak Index in a Mountain Array: Binary Search on Shape
mediumHow 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.
Number of Lines To Write String: Greedy Line Filling
easyHow 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.
New 21 Game: Sliding Window DP Explained
mediumHow to solve LeetCode 837 New 21 Game using dynamic programming with a sliding window. Visual walkthrough of probability calculations.
Most Profit Assigning Work: Greedy Job Assignment
mediumHow to solve LeetCode 826 Most Profit Assigning Work using sorting and two pointers. Visual walkthrough of greedy profit maximization for worker-job assignment.
Most Common Word: Filtering and Counting with Hash Maps
easyHow to solve LeetCode 819 Most Common Word by normalizing text, filtering banned words, and counting frequencies. Visual walkthrough of string parsing with hash maps.
Mirror Reflection: Unfolding a Laser Beam with GCD
mediumHow to solve LeetCode 858 Mirror Reflection. Unfold the mirror room into stacked copies and use GCD to determine which receptor the laser hits.
Minimum Cost to Hire K Workers: Greedy Ratios with a Max-Heap
hardHow 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.
Maximize Distance to Closest Person: Gap Scanning
mediumHow to solve LeetCode 849 Maximize Distance to Closest Person by scanning gaps between occupied seats. Find the optimal empty seat in one pass.
Max Increase to Keep City Skyline: Row and Column Constraints
mediumHow 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.
Masking Personal Information: String Parsing
mediumHow to solve LeetCode 831 Masking Personal Information by detecting emails vs phone numbers and applying masking rules. Visual walkthrough of the parsing approach.
Making A Large Island: Union-Find Grid Strategy
hardHow 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.
Magic Squares In Grid: Subgrid Validation Explained
mediumHow to solve LeetCode 840 Magic Squares In Grid. Visual walkthrough of sliding window validation for 3x3 magic squares.
Loud and Rich: DFS on a Wealth Graph
mediumHow 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.
Longest Mountain in Array: Expand From Peaks
mediumHow 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.
Linked List Components: Counting Connected Subgroups
mediumHow to solve LeetCode 817 Linked List Components by traversing the list and counting transitions out of a subset. Visual walkthrough with hash set lookup.
Lemonade Change: Greedy Change-Making
easyHow to solve LeetCode 860 Lemonade Change using a greedy approach. Track bill counts and always prefer giving a ten-dollar bill as change.
Largest Triangle Area: Brute Force with the Shoelace Formula
easyHow to solve LeetCode 812 Largest Triangle Area by trying all point triples and computing area with the Shoelace formula.
Largest Sum of Averages: Partition DP with Prefix Sums
mediumHow to solve LeetCode 813 Largest Sum of Averages using dynamic programming with prefix sums to maximize the sum of group averages.
Keys and Rooms: Graph Traversal Explained
mediumHow to solve LeetCode 841 Keys and Rooms using DFS. Visual walkthrough of graph reachability from a starting node.
Image Overlap: Translation Vector Counting
mediumHow to solve LeetCode 835 Image Overlap by counting translation vectors. An elegant approach using coordinate pairs and hash maps.
Hand of Straights: Greedy Grouping with Frequency Counting
mediumHow to solve LeetCode 846 Hand of Straights using a greedy approach with sorted iteration and a frequency map. Step-by-step visual walkthrough.
Guess the Word: Minimax Elimination Strategy
hardHow to solve LeetCode 843 Guess the Word using a minimax approach. Visual walkthrough of narrowing a word list through strategic guessing.
Goat Latin: String Transformation Word by Word
easyHow to solve LeetCode 824 Goat Latin by processing each word based on its first character. Visual walkthrough of vowel and consonant transformation rules.
Friends Of Appropriate Ages: Counting Valid Friend Requests
mediumHow to solve LeetCode 825 Friends Of Appropriate Ages using age frequency counting. Visual walkthrough of the friend request conditions and counting approach.
Flipping an Image: Row Reverse and Bit Flip
easyHow to solve LeetCode 832 Flipping an Image. Reverse each row and flip bits in a single pass with Python.
Find Eventual Safe States: Graph Cycle Detection
mediumHow 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.
Find And Replace in String: Right-to-Left Replacement
mediumHow to solve LeetCode 833 Find And Replace in String. Process replacements from right to left to avoid index shifting.
Expressive Words: Two-Pointer Group Matching
mediumHow 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.
Count Unique Characters of All Substrings: Contribution Counting
hardHow to solve LeetCode 828 Count Unique Characters of All Substrings using per-character contribution counting. Visual walkthrough of the O(n) approach.
Consecutive Numbers Sum: Mathematical Decomposition
hardHow to solve LeetCode 829 Consecutive Numbers Sum using arithmetic series math. Visual walkthrough of finding all ways to express n as consecutive integers.
Card Flipping Game: Finding the Minimum Good Number
mediumHow 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.
Car Fleet: Sort and Stack to Count Collisions
mediumHow to solve LeetCode 853 Car Fleet. Sort cars by position, compute arrival times, and use a stack-based greedy approach to count distinct fleets.
Buddy Strings: One Swap to Make Strings Equal
easyHow to solve LeetCode 859 Buddy Strings. Find differing positions between two strings and check if exactly one swap makes them equal.
Binary Trees With Factors: Counting Factor Trees with DP
mediumHow to solve LeetCode 823 Binary Trees With Factors using dynamic programming on sorted values. Visual walkthrough of counting trees where parent equals child product.
Binary Tree Pruning: Post-Order Subtree Removal
mediumHow to solve LeetCode 814 Binary Tree Pruning using post-order traversal to remove subtrees that contain no 1s.
Backspace String Compare: Stack and Two-Pointer Solutions
easyHow 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.
Ambiguous Coordinates: Generating Valid Number Pairs
mediumHow to solve LeetCode 816 Ambiguous Coordinates by splitting a digit string and inserting decimal points. Visual walkthrough of enumeration with validity checks.
All Nodes Distance K in Binary Tree: Parent Pointers and BFS
mediumHow 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.
Valid Tic-Tac-Toe State: Invariant Checking
mediumHow 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.
Toeplitz Matrix: Diagonal Consistency Check
easyHow 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.
Swim in Rising Water: Binary Search Meets Graph Traversal
hardHow to solve LeetCode 778 Swim in Rising Water with binary search + BFS or min-heap. Visual grid walkthrough.
Subarray Product Less Than K: Sliding Window on Products
mediumHow to solve LeetCode 713 Subarray Product Less Than K using a sliding window to count valid subarrays in O(n) time.
Split Linked List in Parts: Even Distribution with Remainders
mediumHow to solve LeetCode 725 Split Linked List in Parts by computing base size and distributing remainder nodes. O(n) solution explained with visual walkthrough.
Sliding Puzzle: BFS on Board States
hardHow to solve LeetCode 773 Sliding Puzzle using BFS. Visual walkthrough of state-space search on a 2x3 board.
Shortest Completing Word: Frequency Counting with Hash Maps
easyHow to solve LeetCode 748 by counting letter frequencies and checking each candidate word. Visual walkthrough of the matching process.
Set Intersection Size At Least Two: Greedy Interval Covering
hardHow 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.
Self Dividing Numbers: Check Every Digit
easyHow to solve LeetCode 728 Self Dividing Numbers. Simple digit-by-digit divisibility check with clean Python code.
Rotate String: The Concatenation Trick
easyHow to solve LeetCode 796 by checking if goal is a substring of s+s. Visual walkthrough of the rotation insight.
Reorganize String: Greedy Character Spacing
mediumHow 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.
Remove Comments: Parsing with a State Machine
mediumHow 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.
Reach a Number: Greedy Steps with Parity Flip
mediumHow 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.
Pyramid Transition Matrix: Backtracking with Allowed Triples
mediumHow to solve LeetCode 756 Pyramid Transition Matrix using backtracking to build each row from allowed triple rules. Visual walkthrough of the recursive approach.
Prime Number of Set Bits in Binary Representation: Counting Bits with a Twist
easyHow to solve LeetCode 762 by counting set bits for each number in a range and checking whether the count is prime.
Preimage Size of Factorial Zeroes Function: Binary Search on Math
hardHow 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!.
Prefix and Suffix Search: Trie with Combined Keys
hardHow 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.
Prefix and Suffix Search: Combined Key Trie
hardHow 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.
Partition Labels: Greedy String Partitioning
mediumHow to solve LeetCode 763 Partition Labels by greedily splitting a string so each letter appears in at most one part.
Open the Lock: BFS Shortest Path on State Graph
mediumHow 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.
Number of Subarrays with Bounded Maximum
mediumHow to solve LeetCode 795 by counting valid subarrays with a two-pointer sweep. Visual walkthrough of the boundary tracking approach.
Number of Matching Subsequences: Bucket Processing
mediumHow 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.
Number of Atoms: Stack-Based Formula Parsing
hardHow 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.
Network Delay Time: Dijkstra's Algorithm
mediumHow to solve LeetCode 743 Network Delay Time with Dijkstra's shortest path algorithm using a min-heap, with Python code and visual walkthrough.
My Calendar III: Maximum K-Booking with Sweep Line
hardHow to solve LeetCode 732 My Calendar III. Use the sweep line technique with a sorted difference map to find the maximum overlap count.
My Calendar II: Preventing Triple Bookings
mediumHow to solve LeetCode 731 My Calendar II. Track double bookings separately to prevent triple overlaps with a clean Python solution.
My Calendar I: Interval Overlap Detection
mediumHow to solve LeetCode 729 My Calendar I. Learn interval overlap detection with a sorted list approach and clean Python solution.
Monotone Increasing Digits: Greedy Digit Manipulation
mediumHow to solve LeetCode 738 Monotone Increasing Digits with a greedy approach that scans digits right to left, with Python code and visual walkthrough.
Minimum Swaps To Make Sequences Increasing
hardHow to solve LeetCode 801 with a two-state DP tracking swap and no-swap decisions at each index. Visual walkthrough of the state transitions.
Minimum Distance Between BST Nodes: Inorder Traversal
easyHow to solve LeetCode 783 Minimum Distance Between BST Nodes with inorder traversal. Visual BST walkthrough.
Min Cost Climbing Stairs: Bottom-Up DP
easyHow to solve LeetCode 746 with dynamic programming. Visual walkthrough of the cost array and optimal substructure.
Maximum Length of Repeated Subarray: DP Table Matching
mediumHow to solve LeetCode 718 Maximum Length of Repeated Subarray using dynamic programming to find the longest common subarray in O(m*n) time.
Max Chunks To Make Sorted: Running Maximum
mediumHow 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.
Max Chunks To Make Sorted II: Prefix Max and Suffix Min
hardHow 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.
Longest Word in Dictionary: Building Words Character by Character
mediumHow 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.
Letter Case Permutation: Branching on Every Letter
mediumHow to solve LeetCode 784 Letter Case Permutation using backtracking and bit manipulation. Decision tree, step-by-step walkthrough, and complexity analysis.
Largest Plus Sign: Dynamic Programming on a Grid
mediumHow 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.
Largest Number At Least Twice of Others: Single Pass Array Scan
easyHow to solve LeetCode 747 by tracking the two largest elements in one pass. Visual walkthrough of the dominance check.
K-th Symbol in Grammar: Recursive Binary Pattern
mediumHow to solve LeetCode 779 K-th Symbol in Grammar using recursion. Visual tree showing how each row generates the next.
Jewels and Stones: Set Membership Counting
easyHow 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.
Is Graph Bipartite: Two-Color BFS on an Adjacency List
mediumHow 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).
Global and Local Inversions: The Key Insight
mediumHow to solve LeetCode 775 Global and Local Inversions. Visual explanation of why local inversions are always global, and the one-pass check.
Flood Fill: DFS on a Grid
easyHow to solve LeetCode 733 Flood Fill. A clean DFS approach to filling connected regions in a matrix with Python code.
Find Smallest Letter Greater Than Target: Binary Search on Letters
easyHow to solve LeetCode 744 with binary search on a sorted character array. Visual walkthrough of pointer movement and wrap-around logic.
Find Pivot Index: Prefix Sum Balance Point
easyHow 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.
Escape The Ghosts: Manhattan Distance Insight
mediumHow 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.
Domino and Tromino Tiling: Dynamic Programming on a Grid
mediumHow to solve LeetCode 790 Domino and Tromino Tiling using dynamic programming. Track full and partial row states to count all valid 2xN tilings.
Delete and Earn: House Robber in Disguise
mediumHow to solve LeetCode 740 Delete and Earn by reducing it to the House Robber problem, with Python code and visual walkthrough.
Custom Sort String: Hash Map Counting Approach
mediumHow to solve LeetCode 791 Custom Sort String using character counting and custom ordering. Count characters in s, then reconstruct in the order specified.
Cracking the Safe: Eulerian Path on De Bruijn Graph
hardHow to solve LeetCode 753 Cracking the Safe by finding an Eulerian path through a De Bruijn graph. Visual walkthrough of the DFS-based approach.
Couples Holding Hands: Greedy Swaps and Union-Find
hardHow to solve LeetCode 765 Couples Holding Hands by greedily swapping people into the correct seats, with an alternative union-find cycle counting approach.
Cherry Pickup: Two-Path DP on a Grid
hardHow to solve LeetCode 741 Cherry Pickup using dynamic programming with two simultaneous walkers, with Python code and visual walkthrough.
Cheapest Flights Within K Stops: Bounded Bellman-Ford
mediumHow to solve LeetCode 787 Cheapest Flights Within K Stops using a modified Bellman-Ford algorithm with bounded iterations, with Python code and visual walkthrough.
Champagne Tower: Simulation with Dynamic Programming
mediumHow to solve LeetCode 799 by simulating champagne overflow row by row. Visual walkthrough of the glass pyramid DP approach.
Best Time to Buy and Sell Stock with Transaction Fee: DP State Machine
mediumHow to solve LeetCode 714 Best Time to Buy and Sell Stock with Transaction Fee using a two-state DP approach in O(n) time.
Asteroid Collision: Stack Simulation
mediumHow to solve LeetCode 735 Asteroid Collision using a stack to simulate asteroid movement and collisions, with Python code and visual walkthrough.
All Paths From Source to Target
mediumHow to solve LeetCode 797 using DFS backtracking on a DAG. Visual walkthrough of finding every path from node 0 to node n-1.
Accounts Merge: Union-Find on Shared Emails
mediumHow to solve LeetCode 721 Accounts Merge using union-find to group accounts by shared emails. O(n alpha(n)) solution explained with visual walkthrough.
1-bit and 2-bit Characters: Greedy Bit Scanning
easyHow 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.
Valid Parenthesis String: Greedy Range Tracking
mediumHow to solve LeetCode 678. Track the range of possible open parenthesis counts to handle wildcards in one pass.
Valid Palindrome II: One Deletion Palindrome Check
easyHow to solve LeetCode 680 Valid Palindrome II using two pointers with one allowed deletion.
Two Sum IV - Input is a BST: Hash Set Tree Traversal
easyHow 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.
Trim a Binary Search Tree: Recursive Range Pruning
mediumHow 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.
Top K Frequent Words: Heap with Lexicographic Tie-Breaking
mediumHow to solve LeetCode 692 Top K Frequent Words using a heap with custom comparator for lexicographic ordering.
To Lower Case: ASCII Arithmetic and Bit Manipulation
easyHow 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.
Stickers to Spell Word: BFS on Letter States
hardHow to solve LeetCode 691 Stickers to Spell Word using BFS with frequency counting and pruning. Visual diagrams and step-by-step walkthrough.
Split Array into Consecutive Subsequences: Greedy Allocation
mediumHow to solve LeetCode 659 Split Array into Consecutive Subsequences using a greedy approach with frequency counting and subsequence tracking.
Solve the Equation: Parsing and Simplifying Linear Equations
mediumHow to solve LeetCode 640 Solve the Equation by parsing both sides and collecting coefficients.
Shopping Offers: Backtracking with Memoization
mediumHow to solve LeetCode 638 Shopping Offers using backtracking with memoization to find the minimum cost.
Set Mismatch: Finding the Duplicate and Missing Number
easyHow to solve LeetCode 645 Set Mismatch by finding the duplicated and missing numbers using a hash set or in-place marking.
Second Minimum Node in a Binary Tree: DFS with Pruning
easyHow to solve LeetCode Second Minimum Node in a Binary Tree. Use DFS to find the smallest value that is strictly larger than the root.
Search in a Binary Search Tree: Using the BST Property
easyHow to solve LeetCode 700 Search in a Binary Search Tree with recursive and iterative approaches. Visual walkthrough of BST navigation.
Robot Return to Origin: Coordinate Tracking
easyHow to solve LeetCode 657 Robot Return to Origin by tracking x and y coordinate changes through a sequence of moves.
Replace Words: Prefix Matching with a Trie
mediumHow to solve LeetCode 648 Replace Words by building a trie from root words and replacing sentence words with their shortest matching prefix.
Repeated String Match: Minimum Repetitions for Substring
mediumHow to solve LeetCode 686 Repeated String Match by finding the minimum number of times to repeat a string so another is a substring.
Redundant Connection: Union-Find Cycle Detection
mediumHow to solve LeetCode 684 Redundant Connection using union-find to detect the edge that creates a cycle.
Redundant Connection II: Directed Graph Cycle Detection
hardHow to solve LeetCode 685 Redundant Connection II by handling two-parent nodes and cycles in directed graphs.
Print Binary Tree: Level-by-Level Grid Placement
mediumHow to solve LeetCode 655 Print Binary Tree by recursively placing nodes into a 2D grid based on tree height and column offsets.
Partition to K Equal Sum Subsets: Backtracking with Pruning
mediumHow to solve LeetCode 698 Partition to K Equal Sum Subsets using backtracking and bitmask DP. Visual walkthrough of bucket-filling and pruning strategies.
Number of Longest Increasing Subsequence: DP with Length and Count
mediumHow to solve LeetCode Number of Longest Increasing Subsequence. Track both the length and count of LIS ending at each position using DP.
Non-negative Integers without Consecutive Ones: Fibonacci DP on Bits
hardHow 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.
Non-decreasing Array: One Modification Check
mediumHow 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.
Minimum Index Sum of Two Lists: Hash Map Index Tracking
easyHow 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.
Minimum ASCII Delete Sum for Two Strings: DP on String Pairs
mediumHow 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.
Maximum Width of Binary Tree: Index-Based BFS
mediumHow 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.
Maximum Swap: Greedy Digit Swap
mediumHow to solve LeetCode Maximum Swap. A greedy approach that tracks the last occurrence of each digit to find the optimal swap.
Maximum Sum of 3 Non-Overlapping Subarrays: Left-Middle-Right Scan
hardHow 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.
Maximum Length of Pair Chain: Greedy Interval Selection
mediumHow to solve LeetCode 646 Maximum Length of Pair Chain using a greedy approach that sorts by end value and selects non-overlapping pairs.
Maximum Binary Tree: Recursive Array Partitioning
mediumHow 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.
Maximum Average Subarray I: Fixed-Size Sliding Window
easyHow to solve LeetCode 643 Maximum Average Subarray I using a fixed-size sliding window for O(n) performance.
Max Area of Island: DFS Grid Exploration
mediumHow to solve LeetCode 695 Max Area of Island using DFS to explore connected components in a grid.
Map Sum Pairs: Prefix Sums in a Trie
mediumHow to solve LeetCode 677. Use a trie with running sums at each node to efficiently compute prefix-based value totals.
Longest Univalue Path: DFS Post-Order Counting
mediumHow to solve LeetCode 687 Longest Univalue Path using DFS post-order traversal. O(n) solution with visual diagrams and step-by-step walkthrough.
Longest Continuous Increasing Subsequence: Sliding Window Counter
easyHow to solve LeetCode Longest Continuous Increasing Subsequence. A single pass tracking the current run length with O(n) time and O(1) space.
Kth Smallest Number in Multiplication Table: Binary Search on Value
hardHow 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.
Kth Largest Element in a Stream: Min-Heap Design
easyHow 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.
Knight Probability in Chessboard: Layer-by-Layer DP
mediumHow to solve LeetCode 688 Knight Probability in Chessboard using dynamic programming. O(n^2 * k) solution with visual diagrams and step-by-step walkthrough.
Insert into a Binary Search Tree: Finding the Right Leaf
mediumHow to solve LeetCode 701 Insert into a Binary Search Tree with recursive and iterative approaches. Visual walkthrough of BST insertion.
Implement Magic Dictionary: One-Character Fuzzy Matching
mediumHow to solve LeetCode 676. Group words by length and check for exactly one character difference to implement fuzzy search.
Image Smoother: Neighbor Averaging
easyHow to solve LeetCode 661 Image Smoother by averaging each cell with its valid neighbors in a 3x3 window.
Find K Closest Elements: Binary Search Window
mediumHow to solve LeetCode 658 Find K Closest Elements using binary search to locate the optimal sliding window of k elements closest to a target.
Find Duplicate Subtrees: Serialization with Hash Map
mediumHow to solve LeetCode 652 Find Duplicate Subtrees. Serialize each subtree during post-order traversal and use a hash map to detect duplicates.
Falling Squares: Coordinate Compression and Interval Tracking
hardHow to solve LeetCode 699 Falling Squares using coordinate compression and interval height tracking. Visual walkthrough of square stacking.
Employee Importance: BFS Graph Traversal
mediumHow 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.
Dota2 Senate: Greedy Voting with Two Queues
mediumHow to solve LeetCode 649 Dota2 Senate using a greedy two-queue simulation where each senator bans the nearest opposing member.
Design Linked List: Build a Linked List From Scratch
mediumHow to solve LeetCode 707 Design Linked List. Implement get, addAtHead, addAtTail, addAtIndex, and deleteAtIndex using a singly linked list with a dummy head.
Design HashSet: Build a Hash Set From Scratch
easyHow to solve LeetCode 705 Design HashSet. Implement add, remove, and contains using an array of buckets with chaining in O(1) average time.
Design HashMap: Implement a Hash Map From Scratch
easyHow to solve LeetCode 706 Design HashMap. Build put, get, and remove operations using bucket arrays with chaining for O(1) average time.
Design Circular Deque: Array-Based Ring Buffer
mediumHow to solve LeetCode 641 Design Circular Deque using a circular array with front and rear pointers.
Degree of an Array: Hash Map Tracking
easyHow to solve LeetCode 697 Degree of an Array by tracking frequency, first occurrence, and last occurrence in a single pass.
Cut Off Trees for Golf Event: BFS on a Matrix Grid
hardHow to solve LeetCode 675. Sort trees by height, then use BFS to find shortest paths between each consecutive pair.
Count Binary Substrings: The Group Counting Trick
easyHow to solve LeetCode 696 Count Binary Substrings in O(n) time by counting consecutive groups.
Bulb Switcher II: Pattern Analysis with Four Operations
mediumHow to solve LeetCode Bulb Switcher II. Why the answer only depends on the first three bulbs and how to count distinct states.
Binary Number with Alternating Bits: The XOR Trick
easyHow to solve LeetCode 693 Binary Number with Alternating Bits using XOR and bit manipulation in O(1) space.
Beautiful Arrangement II: Constructing k Distinct Differences
mediumHow 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.
Baseball Game: Stack-Based Score Tracking
easyHow to solve LeetCode 682 Baseball Game using a stack to track and manipulate scores.
Average of Levels in Binary Tree: BFS Level-by-Level
easyHow to solve LeetCode 637 Average of Levels in Binary Tree using BFS to compute level averages.
24 Game: Backtracking with Arithmetic Expressions
hardHow to solve LeetCode 679. Recursively pick two numbers, apply an operation, reduce the list, and check if 24 is reachable.
2 Keys Keyboard: Prime Factorization Meets Dynamic Programming
mediumHow to solve LeetCode 650 2 Keys Keyboard by recognizing that the minimum operations equal the sum of the prime factors of n.
Valid Triangle Number: Sort, Fix, Two Pointers
mediumHow 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.
Sum of Square Numbers: Two-Pointer Search for Perfect Squares
mediumHow 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.
Subarray Sum Equals K: Prefix Sums Meet Hash Maps
mediumHow to solve LeetCode 560 Subarray Sum Equals K using prefix sums and a hash map to count subarrays in O(n) time.
Student Attendance Record I: Single-Pass String Check
easyHow to solve LeetCode 551 Student Attendance Record I by counting absences and tracking consecutive lates in one pass through the string.
Smallest Range Covering Elements from K Lists: Min-Heap Approach
hardHow to solve LeetCode 632 Smallest Range Covering Elements from K Lists using a min-heap to track pointers across sorted lists.
Single Element in a Sorted Array: Binary Search on Pairs
mediumHow to solve LeetCode 540 Single Element in a Sorted Array using binary search with the even-odd index trick in O(log n) time.
Shortest Unsorted Continuous Subarray: Finding the Minimum Slice to Sort
mediumHow to solve LeetCode 581 Shortest Unsorted Continuous Subarray in O(n) time by tracking max from the left and min from the right.
Reverse Words in a String III: Per-Word Reversal in One Line
easyHow to solve LeetCode 557 Reverse Words in a String III by splitting, reversing each word, and joining back together.
Reverse String II: Chunked Reversal Pattern
easyHow to solve LeetCode 541 Reverse String II by processing the string in 2k-sized chunks and reversing the first k characters of each.
Reshape the Matrix: Row-Major Index Mapping
easyHow to solve LeetCode 566 Reshape the Matrix using row-major order index conversion between matrix shapes.
Range Addition II: Finding the Overlap of All Operations
easyHow to solve LeetCode 598 Range Addition II by finding the intersection of all operation rectangles. The maximum value cells form the smallest overlapping region.
Random Pick with Weight: Prefix Sums + Binary Search
mediumHow 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.
Permutation in String: Fixed-Size Sliding Window with Frequency Matching
mediumHow to solve LeetCode 567 Permutation in String using a sliding window and character frequency comparison.
Out of Boundary Paths: 3D Dynamic Programming on a Grid
mediumHow 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.
Optimal Division: Why Greedy Parentheses Always Win
mediumHow to solve LeetCode 553 Optimal Division using the mathematical insight that placing parentheses around all denominators maximizes the result.
Number of Provinces: Union-Find for Connected Components
mediumHow to solve LeetCode 547 Number of Provinces using Union-Find with path compression and union by rank to count connected components.
Non-negative Integers without Consecutive Ones: A Fibonacci DP Approach
hardHow to solve LeetCode 600 by counting integers without consecutive ones in binary using a Fibonacci-based digit DP technique.
Next Greater Element III: Next Permutation on Digits
mediumHow to solve LeetCode 556 Next Greater Element III by applying the next permutation algorithm to the digits of an integer.
N-ary Tree Preorder Traversal: DFS Without Recursion
easyHow to solve LeetCode 589 N-ary Tree Preorder Traversal using iterative DFS with a stack. Visual walkthrough of processing root before children.
N-ary Tree Postorder Traversal: Process Children Before Parents
easyHow to solve LeetCode 590 N-ary Tree Postorder Traversal using an iterative two-stack approach. Visual walkthrough of visiting children before the root.
Minimum Time Difference: Circular Sort Trick
mediumHow to solve LeetCode 539 Minimum Time Difference by converting to minutes, sorting, and checking the circular wrap-around.
Minimum Index Sum of Two Lists: Finding Common Favorites Efficiently
easyHow to solve LeetCode 599 Minimum Index Sum of Two Lists using a hash map to find shared elements with the smallest combined index.
Minimum Absolute Difference in BST: Inorder Traversal for Sorted Order
easyHow 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.
Minesweeper: Matrix DFS with Recursive Reveal
mediumHow to solve LeetCode 529 Minesweeper using DFS. Count adjacent mines, reveal blanks recursively, and stop at numbered borders.
Merge Two Binary Trees: Recursive DFS in One Pass
easyHow to solve LeetCode 617 Merge Two Binary Trees using recursive DFS. A clean pattern for combining two tree structures node by node.
Maximum Product of Three Numbers: Why Negatives Matter
easyHow to solve LeetCode 628 Maximum Product of Three Numbers. Sorting and linear scan approaches with complexity analysis.
Longest Word in Dictionary through Deleting: Two-Pointer Subsequence Check
mediumHow 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.
Longest Uncommon Subsequence II: Filtering Candidates with Subsequence Checks
mediumHow 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.
Longest Uncommon Subsequence I: The Trick Question
easyHow 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.
Longest Palindromic Subsequence: 2D Dynamic Programming
mediumHow to solve LeetCode 516 Longest Palindromic Subsequence using 2D DP. Visual walkthrough of the interval DP table.
Longest Harmonious Subsequence: Counting Adjacent Value Pairs
easyHow 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.
K Inverse Pairs Array: Counting Permutations with DP
hardHow to solve LeetCode 629 K Inverse Pairs Array using dynamic programming with prefix sums to count permutations with exactly k inverse pairs.
K-diff Pairs in an Array: Hash Map for Target Differences
mediumHow 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.
Freedom Trail: Ring DP with Position Tracking
hardHow to solve LeetCode 514 Freedom Trail using dynamic programming. Visual walkthrough of minimum rotation cost on a circular ring.
Fraction Addition and Subtraction: Parsing and Reducing Fractions
mediumHow to solve LeetCode 592 Fraction Addition and Subtraction by parsing fraction strings and accumulating results with GCD reduction.
Find Largest Value in Each Tree Row: BFS Level Maximums
mediumHow to solve LeetCode 515 Find Largest Value in Each Tree Row using BFS. Visual walkthrough of tracking maximums during level-order traversal.
Find Duplicate File in System: Grouping by Content with Hash Maps
mediumHow to solve LeetCode 609 Find Duplicate File in System by parsing directory strings and grouping files with identical content using a hash map.
Find Bottom Left Tree Value: BFS Level-by-Level
mediumHow 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.
Fibonacci Number: Bottom-Up Dynamic Programming
easyHow to solve LeetCode 509 Fibonacci Number using bottom-up dynamic programming. Visual walkthrough of the DP table approach.
Exclusive Time of Functions: Stack-Based Execution Tracking
mediumHow to solve LeetCode 636 Exclusive Time of Functions using a stack to track nested function calls and compute exclusive execution times.
Erect the Fence: Convex Hull with Monotone Chain
hardHow 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.
Encode and Decode TinyURL: Hash Map Design with Random Keys
mediumHow to solve LeetCode 535 Encode and Decode TinyURL. Design a URL shortening service using a bidirectional hash map with random key generation.
Distribute Candies: Sets, Limits, and One Line of Insight
easyHow to solve LeetCode 575 Distribute Candies using a set to count unique types and a simple min comparison.
Detect Capital: Counting Uppercase Letters
easyHow to solve LeetCode 520 Detect Capital by counting uppercase letters. One-pass O(n) solution with visual diagrams.
Design Circular Queue: Array-Based Ring Buffer
mediumHow to solve LeetCode 622 Design Circular Queue using a fixed-size array with front and rear pointers. Modular arithmetic handles the wrap-around.
Delete Operation for Two Strings: Minimum Deletions via LCS
mediumHow 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.
Course Schedule III: Maximizing Courses with Greedy + Heap
hardHow to solve LeetCode 630 Course Schedule III using a greedy approach with a max-heap to maximize the number of courses you can take.
Convert BST to Greater Tree: Reverse Inorder Traversal
mediumHow to solve LeetCode 538 Convert BST to Greater Tree. Use reverse inorder traversal to accumulate a running sum and update each node in-place.
Continuous Subarray Sum: Prefix Sums Meet Modular Arithmetic
mediumHow to solve LeetCode 523 Continuous Subarray Sum using prefix sums with modular arithmetic and a hash map. Visual walkthrough with step-by-step diagrams.
Contiguous Array: Finding Equal 0s and 1s with Prefix Sums
mediumHow 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.
Construct String from Binary Tree: Preorder with Parentheses
mediumHow to solve LeetCode 606 Construct String from Binary Tree using preorder traversal with selective parentheses for unambiguous representation.
Complex Number Multiplication: Parsing and Math
mediumHow to solve LeetCode 537 Complex Number Multiplication. Parse the string format, apply the multiplication formula, and format the result.
Coin Change II: Counting Combinations with DP
mediumHow to solve LeetCode 518 Coin Change II with bottom-up dynamic programming. Visual walkthrough of the unbounded knapsack counting pattern.
Can Place Flowers: Greedy Planting in a Flowerbed
easyHow to solve LeetCode 605 Can Place Flowers using a greedy scan to place flowers without violating adjacency rules.
Binary Tree Tilt: Post-Order DFS with Subtree Sums
easyHow to solve LeetCode 563 Binary Tree Tilt using post-order traversal to compute subtree sums and accumulate tilt values.
Beautiful Arrangement: Backtracking with Divisibility Pruning
mediumHow to solve LeetCode 526 Beautiful Arrangement using backtracking with divisibility checks. Visual decision tree and bitmask DP alternative explained.
Array Partition: Greedy Pairing After Sorting
easyHow to solve LeetCode 561 Array Partition by sorting and pairing adjacent elements for maximum sum of minimums.
Array Nesting: Finding the Longest Cycle in a Permutation
mediumHow to solve LeetCode 565 Array Nesting by recognizing permutation cycles and using visited marking for O(n) time.
Add One Row to Tree: BFS Insertion at a Target Depth
mediumHow 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.
01 Matrix: Multi-Source BFS for Nearest Zero
mediumHow 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.
Validate IP Address: Parsing IPv4 and IPv6
mediumHow to solve LeetCode 468 Validate IP Address by splitting the string and checking each segment against IPv4 and IPv6 rules.
Total Hamming Distance: Counting Bits Column by Column
mediumHow to solve LeetCode 477 Total Hamming Distance by counting set bits at each position and multiplying ones by zeros.
Teemo Attacking: Merging Overlapping Intervals
easyHow to solve LeetCode 495 Teemo Attacking by calculating total poison duration with overlapping intervals. Visual walkthrough of the linear scan approach.
Target Sum: From Brute Force to Subset Sum DP
mediumHow 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.
String Compression: Two Pointer In-Place Encoding
mediumHow to solve LeetCode 443 String Compression using the two-pointer technique to compress characters in place.
Sort Characters By Frequency: Bucket Sort Approach
mediumHow to solve LeetCode 451 Sort Characters By Frequency using hash map counting and bucket sort for O(n) time.
Sliding Window Median: Two Heaps with Lazy Deletion
hardHow to solve LeetCode 480 Sliding Window Median using two heaps with lazy deletion. Find the median in every window of size k efficiently.
Serialize and Deserialize BST: Preorder with Bounds
mediumHow to solve LeetCode 449 Serialize and Deserialize BST using preorder traversal and bound-based reconstruction.
Reverse Pairs: Merge Sort for Counting Inversions
hardHow 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.
Repeated Substring Pattern: The Double String Trick
easyHow to solve LeetCode 459 Repeated Substring Pattern using the string concatenation method.
Relative Ranks: Sorting with Index Tracking
easyHow to solve LeetCode 506 Relative Ranks using sorting with original indices. Visual walkthrough of the rank assignment pattern.
Reconstruct Original Digits from English: Letter Frequency Trick
mediumHow to solve LeetCode 423 Reconstruct Original Digits from English using unique letter identification. Visual walkthrough of the frequency-based approach.
Predict the Winner: Game Theory DP
mediumHow 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.
Perfect Number: Divisor Sum with Square Root Optimization
easyHow to solve LeetCode 507 Perfect Number by finding divisors up to the square root. Visual walkthrough of the divisor-pair technique.
Path Sum III: Prefix Sum in Trees
mediumHow 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.
Ones and Zeroes: 2D Knapsack DP
mediumHow to solve LeetCode 474 Ones and Zeroes using a two-dimensional knapsack dynamic programming approach.
Number of Segments in a String: Counting Words Without Split
easyHow to solve LeetCode 434 Number of Segments in a String by counting space-to-character transitions. Visual walkthrough of a clean one-pass approach.
Number Complement: Flipping Bits with XOR
easyHow to solve LeetCode 476 Number Complement by building a bitmask and using XOR to flip all significant bits.
Non-overlapping Intervals: Greedy Interval Scheduling
mediumHow to solve LeetCode 435 Non-overlapping Intervals using greedy interval scheduling. Visual walkthrough of sorting by end time and removing minimum overlapping intervals.
Non-decreasing Subsequences: Backtracking with Deduplication
mediumHow to solve LeetCode 491 Non-decreasing Subsequences using backtracking with set-based deduplication. Visual walkthrough of building valid subsequences while avoiding duplicates.
Next Greater Element II: Circular Array Stack Pattern
mediumHow to solve LeetCode 503 Next Greater Element II using a monotonic stack on a circular array. Visual walkthrough of the doubled-traversal trick.
Next Greater Element I: Stack + Hash Map Pattern
easyHow to solve LeetCode 496 Next Greater Element I using a monotonic stack and hash map. Visual walkthrough of the next-greater-element pattern.
N-ary Tree Level Order Traversal: BFS Beyond Binary Trees
mediumHow to solve LeetCode 429 N-ary Tree Level Order Traversal using BFS. Visual walkthrough of level-by-level processing with a queue.
Most Frequent Subtree Sum: DFS with Frequency Counting
mediumHow to solve LeetCode 508 Most Frequent Subtree Sum using post-order DFS and a hash map. Visual walkthrough of subtree sum collection.
Minimum Number of Arrows to Burst Balloons: Greedy Interval Strategy
mediumHow to solve LeetCode 452 Minimum Number of Arrows to Burst Balloons using greedy interval scheduling.
Minimum Moves to Equal Array Elements: The Decrement Trick
mediumHow to solve LeetCode 453 Minimum Moves to Equal Array Elements using the mathematical equivalence between incrementing n-1 elements and decrementing one.
Minimum Moves to Equal Array Elements II: Why the Median Wins
mediumHow to solve LeetCode 462 Minimum Moves to Equal Array Elements II using the median property for minimum absolute deviations.
Minimum Genetic Mutation: BFS on Gene Strings
mediumHow to solve LeetCode 433 Minimum Genetic Mutation using BFS to find the shortest transformation sequence. Visual walkthrough of gene string graph traversal.
Maximum XOR of Two Numbers in an Array: Bitwise Trie Approach
mediumHow to solve LeetCode 421 Maximum XOR of Two Numbers in an Array using a bitwise trie. Visual walkthrough of greedy XOR maximization.
Max Consecutive Ones: Single Pass Counter
easyHow to solve LeetCode 485 Max Consecutive Ones with a single pass and two variables. Visual walkthrough, Python solution, and building blocks.
Matchsticks to Square: Backtracking with Pruning
mediumHow to solve LeetCode 473 Matchsticks to Square using backtracking to partition matchsticks into four equal-sum groups.
Magical String: Self-Describing Sequence Generation
mediumHow 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.
License Key Formatting: String Manipulation from the Right
easyHow to solve LeetCode 482 License Key Formatting by stripping dashes, uppercasing, and regrouping characters from the right. Visual walkthrough with Python code.
LFU Cache: Frequency-Based Eviction in O(1)
hardHow to solve LeetCode 460 LFU Cache with O(1) get and put using hash maps and doubly linked lists per frequency.
Keyboard Row: Hash Map Row Lookup
easyHow to solve LeetCode 500 Keyboard Row using a hash map for row lookup. Visual walkthrough of the keyboard row pattern.
K-th Smallest in Lexicographical Order: Virtual Trie Traversal
hardHow to solve LeetCode 440 K-th Smallest in Lexicographical Order by counting nodes in a virtual trie without building it.
Island Perimeter: Counting Edges Without DFS
easyHow to solve LeetCode 463 Island Perimeter by counting land cells and subtracting shared edges.
IPO: Greedy Selection with Two Heaps
hardHow to solve LeetCode 502 IPO using a greedy approach with a min-heap and max-heap. Visual walkthrough of the capital maximization pattern.
Implement Rand10 Using Rand7: Rejection Sampling
mediumHow to solve LeetCode 470 Implement Rand10() Using Rand7() with rejection sampling to generate uniform random numbers.
Heaters: Binary Search for Minimum Radius
mediumHow to solve LeetCode 475 Heaters using sorting and binary search to find the minimum heating radius.
Hamming Distance: XOR and Bit Counting
easyHow to solve LeetCode 461 Hamming Distance using XOR and Brian Kernighan's bit counting technique.
Flatten a Multilevel Doubly Linked List: DFS Pointer Manipulation
mediumHow to solve LeetCode 430 Flatten a Multilevel Doubly Linked List using iterative DFS. Visual walkthrough of flattening nested linked list levels.
Find Right Interval: Binary Search on Sorted Starts
mediumHow 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.
Find Mode in Binary Search Tree: Inorder Traversal Pattern
easyHow to solve LeetCode 501 Find Mode in Binary Search Tree using inorder traversal. Visual walkthrough of mode finding in a BST.
Find All Numbers Disappeared in an Array: Index Marking
easyHow 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.
Find All Duplicates in an Array: Index as Hash Map
mediumHow 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.
Find All Anagrams in a String: Sliding Window Frequency Match
mediumHow to solve LeetCode 438 Find All Anagrams in a String using sliding window and character frequency maps.
Diagonal Traverse: Matrix Zigzag Pattern
mediumHow to solve LeetCode 498 Diagonal Traverse with a simulation approach. Visual walkthrough of diagonal zigzag traversal in a matrix.
Delete Node in a BST: Three Cases of Tree Surgery
mediumHow to solve LeetCode 450 Delete Node in a BST by handling the three deletion cases: leaf, one child, and two children.
Construct the Rectangle: Finding the Closest Square
easyHow to solve LeetCode 492 Construct the Rectangle by searching downward from the square root. Visual walkthrough of finding dimensions closest to a square.
Concatenated Words: Word Break for Every Word
hardHow to solve LeetCode 472 Concatenated Words using dynamic programming word break applied to each candidate word.
Circular Array Loop: Fast and Slow Pointers in a Ring
mediumHow to solve LeetCode 457 Circular Array Loop using Floyd's cycle detection with direction constraints.
Battleships in a Board: Count Ships with One Pass
mediumHow to solve LeetCode 419 Battleships in a Board using a single-pass O(1) space approach. Visual walkthrough of counting battleship heads.
Base 7: Number Base Conversion
easyHow to solve LeetCode 504 Base 7 by repeatedly dividing and collecting remainders. Visual walkthrough of base conversion.
Assign Cookies: Greedy Two-Pointer Matching
easyHow to solve LeetCode 455 Assign Cookies using greedy matching with sorted arrays and two pointers.
Arranging Coins: Binary Search on Triangular Numbers
easyHow to solve LeetCode 441 Arranging Coins using binary search to find the largest complete staircase row.
All O'one Data Structure: O(1) Inc, Dec, Max, Min
hardHow 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.
Add Two Numbers II: Stack-Based Linked List Addition
mediumHow to solve LeetCode 445 Add Two Numbers II using stacks to add linked list numbers without reversing.
4Sum II: Hash Map Meet-in-the-Middle
mediumHow to solve LeetCode 454 4Sum II using hash map pairwise sums and the meet-in-the-middle technique.
132 Pattern: Monotonic Stack from the Right
mediumHow to solve LeetCode 456 132 Pattern using a monotonic decreasing stack traversed from right to left.
Wiggle Subsequence (LeetCode 376): Greedy Peak-Valley Count
mediumHow to solve LeetCode Wiggle Subsequence in O(n) time and O(1) space by counting alternating peaks and valleys with a greedy scan.
Wiggle Sort II: The Median Split Interleave
mediumHow 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.
Verify Preorder Serialization of a Binary Tree: Slot Counting
mediumSolve 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.
Valid Perfect Square: Binary Search Without sqrt()
easyHow to solve LeetCode 367 by running binary search on the candidate range instead of using any built-in sqrt function.
UTF-8 Validation: Bit Pattern Matching
mediumHow to solve LeetCode 393 UTF-8 Validation. Check byte sequences against UTF-8 encoding rules using bit manipulation.
Third Maximum Number: Tracking Multiple Maximums
easyHow to solve LeetCode 414 Third Maximum Number by tracking three distinct maximums in a single pass. Visual walkthrough with edge case handling.
Super Ugly Number: Multi-Pointer DP with Custom Primes
mediumHow 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.
Super Pow: Modular Exponentiation on Big Exponents
mediumHow to solve LeetCode 372 by breaking the exponent digit by digit and applying modular arithmetic at every step.
Sum of Two Integers: Adding Without the + Operator
mediumHow to solve LeetCode 371 by simulating binary addition with XOR for the sum bits and AND-shift for the carry.
Sum of Left Leaves: Recursive Tree Traversal
easyHow to solve LeetCode 404 by recursively identifying and summing left leaves in a binary tree.
Split Array Largest Sum: Binary Search on the Answer
hardHow to solve LeetCode 410 Split Array Largest Sum using binary search on the answer space. Visual walkthrough of the greedy validation approach.
Shuffle an Array: The Fisher-Yates Algorithm
mediumHow 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.
Russian Doll Envelopes: LIS with a Sorting Trick
hardHow 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.
Rotate Function: Math Pattern in Rotations
mediumHow to solve LeetCode 396 Rotate Function. Derive each F(k) from F(k-1) using a simple recurrence.
Reverse Vowels of a String: Two Pointers with Conditional Swaps
easyHow to solve LeetCode 345 Reverse Vowels of a String. Two pointers that independently skip consonants before swapping. Python solution with step-by-step walkthrough.
Reverse String: Two-Pointer Swap In-Place
easyHow to solve LeetCode 344 Reverse String using two pointers and in-place swaps. Visual step-by-step walkthrough with Python code.
Remove K Digits: Monotonic Stack Greedy
mediumHow to solve LeetCode 402 by using a monotonic stack to greedily remove the largest digits first to form the smallest possible number.
Remove Duplicate Letters: Greedy Monotonic Stack
mediumHow to solve LeetCode 316 by combining a monotonic stack with a last-occurrence map to build the lexicographically smallest result with no duplicate letters.
Reconstruct Itinerary: Hierholzer's Eulerian Path
hardSolve LeetCode 332 by finding an Eulerian path in a directed graph using DFS with post-order insertion, always choosing the lexicographically smallest destination first.
Random Pick Index: Reservoir Sampling
mediumHow to solve LeetCode 398 Random Pick Index using reservoir sampling. Pick a random index with equal probability in one pass.
Queue Reconstruction by Height: Greedy Insertion
mediumHow to solve LeetCode 406 by sorting people by height descending and inserting each person at their k-index position.
Power of Three: Loop vs. Math
easyTwo 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.
Power of Four
easyHow 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.
Odd Even Linked List: Two-Group Partition
mediumSolve 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.
Nth Digit: Math Pattern Recognition
mediumHow to solve LeetCode 400 Nth Digit by counting digits in number ranges. Find which number and which digit within it.
Minimum Height Trees: Topological Trimming to Find the Center
mediumHow 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.
Mini Parser: Stack-Based Nested List Deserializer
mediumHow to solve LeetCode 385 Mini Parser using a stack to parse a nested integer string into a recursive data structure.
Maximum Product of Word Lengths: Bitmask Intersection
mediumHow 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.
Max Sum of Rectangle No Larger Than K: 2D to 1D with Binary Search
hardHow 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.
Longest Substring with At Least K Repeating Characters
mediumHow to solve LeetCode 395 with divide and conquer. Split on characters that appear fewer than k times.
Longest Increasing Path in a Matrix: DFS with Memoization
hardSolve LeetCode 329 by running DFS from every cell, caching each cell's longest path length so you never recompute the same subproblem twice.
Longest Absolute File Path: Stack-Based Depth Tracking
mediumHow to solve LeetCode 388 Longest Absolute File Path using a hash map to track path lengths at each depth level.
Linked List Random Node: Reservoir Sampling in One Pass
mediumHow 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.
Lexicographical Numbers: DFS Without a Tree
mediumHow to solve LeetCode 386 Lexicographical Numbers by treating 1-n as a virtual trie and walking it with DFS.
Largest Divisible Subset: LIS Applied to Divisibility
mediumHow to solve LeetCode 368 by sorting and running a longest-increasing-subsequence style DP on divisibility chains.
Kth Smallest Element in a Sorted Matrix (LeetCode 378): Binary Search on Value Space
mediumLearn 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.
Is Subsequence: Two-Pointer Matching
easyHow to solve LeetCode 392 Is Subsequence with two pointers. Match characters in order without rearranging.
Intersection of Two Arrays: Set Lookup for Unique Common Elements
easyHow to solve LeetCode 349 Intersection of Two Arrays in O(m+n) using hash sets. Step-by-step walkthrough with visuals.
Intersection of Two Arrays II: Frequency Counting for Duplicate-Aware Intersection
easyHow to solve LeetCode 350 using a frequency counter. Handles duplicates correctly, with step-by-step visuals, complexity analysis, and interview follow-ups.
Integer Replacement: Greedy Bit Manipulation
mediumHow to solve LeetCode 397 Integer Replacement using greedy bit analysis. Choose between n+1 and n-1 for odd numbers based on trailing bits.
Integer Break: The Math Insight That Makes DP Click
mediumHow to solve LeetCode 343 Integer Break using the 3s insight and a clean DP approach. Visual walkthrough with step-by-step table build-up.
Insert Delete GetRandom O(1): Array + HashMap Combo
mediumHow 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.
Insert Delete GetRandom O(1) - Duplicates Allowed
hardHow 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.
Increasing Triplet Subsequence
mediumLearn how a two-pointer greedy approach solves LeetCode 334 in O(n) time and O(1) space by tracking just two sentinel values.
House Robber III: Tree DP
mediumHow 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.
Guess Number Higher or Lower (LeetCode 374): Binary Search on a Hidden Target
easyLearn 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.
Guess Number Higher or Lower II (LeetCode 375): Minimax DP
mediumHow 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.
Frog Jump: Dynamic Programming with Jump States
hardHow to solve LeetCode 403 by tracking possible jump sizes at each stone position using a hash map of sets.
Flatten Nested List Iterator
mediumHow 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.
Fizz Buzz: The Classic Interview Warm-Up
easyHow to solve LeetCode 412 Fizz Buzz cleanly. Why this simple problem reveals important coding habits and how to handle multiple conditions elegantly.
First Unique Character in a String: Frequency Counting
easyHow to solve LeetCode 387 First Unique Character in a String using a hash map to count character frequencies.
Find the Difference: XOR to Spot the Extra Character
easyHow to solve LeetCode 389 Find the Difference using XOR bit manipulation to identify the added character in O(1) space.
Find K Pairs with Smallest Sums: Min-Heap on Sorted Pairs
mediumHow 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.
Evaluate Division: Graph Traversal with Weighted Edges
mediumHow to solve LeetCode 399 Evaluate Division by building a weighted graph and using BFS to find paths between variables.
Elimination Game: Tracking the Head Through Alternating Passes
mediumHow to solve LeetCode 390 Elimination Game by tracking the head position through alternating left-to-right and right-to-left elimination passes.
Design Twitter: Merge K Sorted Lists with a Heap
mediumHow 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.
Decode String: Stack-Based String Building
mediumHow to solve LeetCode 394 Decode String using a stack. Handle nested brackets and repeat counts step by step.
Data Stream as Disjoint Intervals: Sorted Interval Merging
hardHow to solve LeetCode 352 by maintaining a sorted list of disjoint intervals. Covers the merge-on-insert approach, Python SortedList implementation, and complexity tradeoffs.
Counting Bits
easyHow 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.
Count of Smaller Numbers After Self: Binary Indexed Tree Explained
hardHow 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.
Count Numbers with Unique Digits: Combinatorics with Digit DP
mediumHow 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.
Convert a Number to Hexadecimal: Bit Masking
easyHow to solve LeetCode 405 by extracting 4 bits at a time with masking and shifting to build the hexadecimal string.
Combination Sum IV (LeetCode 377): Count All Ordered Combinations
mediumHow to solve LeetCode 377 Combination Sum IV with bottom-up dynamic programming. Visual DP table walkthrough with step-by-step breakdown.
Burst Balloons: Interval DP with the Last-Burst Trick
hardHow 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.
Bulb Switcher: Why Only Perfect Squares Stay On
mediumLeetCode 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.
Binary Watch: Bit Counting Enumeration
easyHow to solve LeetCode 401 Binary Watch by counting set bits across all valid hour and minute combinations.
Best Time to Buy and Sell Stock with Cooldown: State Machine DP
mediumHow to solve LeetCode 309 with a three-state DP machine: held, sold, and rest. Visual walkthrough of the state transitions and recurrence.
Arithmetic Slices: Counting Arithmetic Subarrays
mediumHow to solve LeetCode 413 Arithmetic Slices with a simple DP counter. Visual walkthrough of counting contiguous arithmetic subsequences.
Additive Number: Backtracking Through Numeric Strings
mediumHow to solve LeetCode 306 Additive Number by splitting a string into a valid Fibonacci-like sequence. Visual walkthrough of the backtracking approach.
Add Strings: Digit-by-Digit Addition Without Converting
easyHow to solve LeetCode 415 Add Strings by simulating grade-school addition. Visual walkthrough of the carry-based digit processing approach.
Word Pattern: Bidirectional Hash Map Matching
easyHow to solve LeetCode 290 Word Pattern using two hash maps for bijective mapping. O(n) solution with visual diagrams.
Remove Invalid Parentheses: BFS Approach Explained
hardHow to solve LeetCode 301 Remove Invalid Parentheses using BFS. Visual walkthrough of finding all valid strings with minimum removals.
Range Sum Query Immutable: Prefix Sums Explained
easyHow to solve LeetCode 303 Range Sum Query Immutable using prefix sums. Visual walkthrough of precomputing cumulative sums for O(1) range queries.
Range Sum Query 2D Immutable: 2D Prefix Sums Explained
mediumHow 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.
Peeking Iterator: Wrapper Pattern for Look-Ahead
mediumHow to solve LeetCode 284 Peeking Iterator by wrapping an iterator with a cached peek value. Clean Python solution with visual diagrams.
Nim Game: The Power of Modulo 4
easyHow to solve LeetCode 292 Nim Game with a single line of code. Mathematical proof of the n % 4 strategy with visual diagrams.
Game of Life: In-Place State Encoding
mediumHow to solve LeetCode 289 Game of Life in-place using state encoding. O(m*n) solution with visual diagrams explaining the transition rules.
Find the Duplicate Number: Floyd's Cycle Detection
mediumHow 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.
Find Median from Data Stream: Two Heaps Explained
hardHow 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.
Bulls and Cows: Hash Map Counting Explained
mediumHow to solve LeetCode 299 Bulls and Cows using hash map counting. Visual walkthrough of matching exact and misplaced digits in one pass.
Word Break II: All Valid Sentences with Backtracking
hardHow to solve LeetCode 140 Word Break II using backtracking with memoization. Find every way to split a string into dictionary words.
Two Sum II: Converging Two Pointers on a Sorted Array
mediumHow to solve LeetCode 167 Two Sum II using converging two pointers in O(n) time and O(1) space. Visual walkthrough and building blocks.
The Skyline Problem: Sweep Line with a Max Heap
hardHow to solve LeetCode 218 The Skyline Problem using a sweep line and max heap. O(n log n) solution explained with visual diagrams.
Summary Ranges: Grouping Consecutive Numbers
easyHow to solve LeetCode 228 Summary Ranges by scanning for consecutive groups. O(n) solution with visual walkthrough.
Sort List: Merge Sort on a Linked List
mediumHow 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.
Sliding Window Maximum: Monotonic Deque Mastery
hardHow to solve LeetCode 239 Sliding Window Maximum using a monotonic deque. Find the max in every window of size k in O(n) time.
Single Number: XOR Cancellation in One Pass
easyHow to solve LeetCode 136 Single Number using XOR. Pairs cancel to zero, leaving the lone element. O(n) time, O(1) space.
Single Number III: Finding Two Unique Numbers with XOR
mediumHow to solve LeetCode 260 Single Number III. Find two numbers that appear exactly once when every other number appears twice, using bit manipulation.
Single Number II: Bit Counting Modulo 3
mediumHow 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.
Shortest Palindrome: KMP Trick for Palindromic Prefixes
hardHow to solve LeetCode 214 Shortest Palindrome using the KMP failure function. O(n) solution explained with visual diagrams.
Search a 2D Matrix II: The Staircase Search
mediumHow 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.
Reverse Words in a String: Split, Reverse, Join
mediumHow to solve LeetCode 151 Reverse Words in a String. Two approaches: split-reverse-join and in-place reversal. Python solutions with walkthrough.
Reverse Bits: Bit-by-Bit Reversal
easyHow 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.
Repeated DNA Sequences: Sliding Window with a Hash Set
mediumHow to solve LeetCode 187 Repeated DNA Sequences using a fixed-size sliding window and hash set. O(n) solution with visual walkthrough.
Remove Linked List Elements: Dummy Head Deletion
easyHow 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.
Rectangle Area: Computing Overlap Between Two Rectangles
mediumHow to solve LeetCode 223 Rectangle Area by computing overlap. Clean visual approach with Python solution.
Power of Two: Bit Manipulation One-Liner
easyHow to solve LeetCode 231 Power of Two using bit manipulation. O(1) solution with visual walkthrough of the n & (n-1) trick.
Perfect Squares: Dynamic Programming with Square Numbers
mediumHow to solve LeetCode 279 Perfect Squares with bottom-up DP. Visual table walkthrough showing the unbounded knapsack pattern with perfect squares.
Number of Digit One: Counting by Position
hardHow to solve LeetCode 233 Number of Digit One by analyzing each digit position. O(log n) solution with visual walkthrough.
Move Zeroes: Two Pointers for In-Place Partitioning
easyHow to solve LeetCode 283 Move Zeroes using two pointers. Visual walkthrough of the swap technique that preserves relative order.
Missing Number: XOR and Math Approaches
easyHow 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.
Minimum Size Subarray Sum: Sliding Window in Action
mediumHow to solve LeetCode 209 Minimum Size Subarray Sum with a sliding window. Visual walkthrough of expanding and shrinking windows.
Maximum Gap: Bucket Sort for Linear Time
mediumHow to solve LeetCode 164 Maximum Gap in O(n) time using bucket sort and the pigeonhole principle. Visual walkthrough of the bucket approach.
Max Points on a Line: Slope Counting with GCD
hardHow 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.
Majority Element II: Boyer-Moore Voting for n/3 Threshold
mediumHow to solve LeetCode 229 Majority Element II using extended Boyer-Moore voting. O(n) time, O(1) space solution with visual walkthrough.
Lowest Common Ancestor of a BST: Leverage the Sorted Structure
mediumHow 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.
Kth Smallest Element in a BST: Inorder Traversal Counting
mediumHow to solve LeetCode 230 Kth Smallest Element in a BST using inorder traversal. O(H + k) solution with visual walkthrough.
Isomorphic Strings: Character Mapping with Hash Maps
easyHow to solve LeetCode 205 Isomorphic Strings using two hash maps. Visual walkthrough of bidirectional character mapping.
Intersection of Two Linked Lists: Two-Pointer Length Equalization
easyHow 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.
Integer to English Words: Breaking Numbers into Groups
hardHow to solve LeetCode 273 Integer to English Words. Convert a non-negative integer to its English words representation by processing three-digit groups.
Insertion Sort List: Sorting a Linked List In Place
mediumHow 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.
Implement Stack using Queues: LIFO from FIFO
easyHow to solve LeetCode 225 Implement Stack using Queues. Build a stack from a single queue with O(n) push.
House Robber II: Circular DP
mediumHow to solve LeetCode 213 House Robber II with dynamic programming on a circular street. Visual walkthrough of the two-pass approach.
H-Index: Sorting to Find Your Citation Threshold
mediumHow to solve LeetCode 274 H-Index using sorting. Visual walkthrough of the counting approach and why sorting simplifies the logic.
H-Index II: Binary Search on a Sorted Array
mediumHow 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.
Fraction to Recurring Decimal: Long Division with Cycle Detection
mediumHow 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.
First Bad Version: Binary Search at Its Simplest
easyHow to solve LeetCode 278 First Bad Version with binary search. Visual walkthrough of halving the search space to find the boundary.
Find Minimum in Rotated Sorted Array II: Handling Duplicates
hardHow 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.
Factorial Trailing Zeroes: Counting Factors of Five
mediumHow to solve LeetCode 172 Factorial Trailing Zeroes in O(log n) time by counting factors of 5. No need to compute the factorial itself.
Excel Sheet Column Title: Base-26 Conversion
easyHow 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.
Excel Sheet Column Number: Base-26 to Integer
easyHow 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.
Dungeon Game: Reverse DP for Minimum Health
hardHow 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.
Different Ways to Add Parentheses: Divide and Conquer Expressions
mediumHow to solve LeetCode 241 Different Ways to Add Parentheses. Split at each operator, solve sub-problems recursively, and combine all possible results.
Delete Node in a Linked List: The Copy-and-Skip Trick
mediumHow to solve LeetCode 237 Delete Node in a Linked List. Delete a node when you only have access to that node, not the head.
Course Schedule II: Topological Sort with BFS
mediumHow to solve LeetCode 210 Course Schedule II using topological sort. Visual walkthrough of Kahn's algorithm for finding course ordering.
Count Primes: The Sieve of Eratosthenes
mediumHow to solve LeetCode 204 Count Primes using the Sieve of Eratosthenes. Visual walkthrough of prime counting with O(n log log n) time.
Count Complete Tree Nodes: Binary Search on a Tree
mediumHow to solve LeetCode 222 Count Complete Tree Nodes in O(log^2 n) using tree height checks. Visual walkthrough and clean Python solution.
Contains Duplicate III: Bucket Sort for Value Ranges
hardHow to solve LeetCode 220 Contains Duplicate III using bucket sort. O(n) solution explained with visual diagrams.
Contains Duplicate II: Sliding Window with a Hash Map
easyHow to solve LeetCode 219 Contains Duplicate II using a hash map or sliding window set. O(n) solution explained with visual diagrams.
Compare Version Numbers: Split and Compare Revisions
mediumHow 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.
Combination Sum III: Backtracking with Fixed Size
mediumHow to solve LeetCode 216 Combination Sum III using backtracking with pruning. Clean Python solution with visual walkthrough.
Bitwise AND of Numbers Range: Common Prefix of Binary Representations
mediumHow 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.
Binary Tree Right Side View: Last Node at Each Level
mediumHow 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.
Binary Tree Preorder Traversal: Root, Left, Right
easyHow to solve LeetCode 144 Binary Tree Preorder Traversal with recursive and iterative stack-based approaches. Visual walkthrough of both solutions.
Binary Tree Postorder Traversal: Left, Right, Root
easyHow to solve LeetCode 145 Binary Tree Postorder Traversal with recursive and iterative approaches. Visual walkthrough of the reversed modified preorder technique.
Binary Tree Paths: DFS Path Building
easyHow to solve LeetCode 257 Binary Tree Paths. Find all root-to-leaf paths in a binary tree using depth-first search and string building.
Binary Search Tree Iterator: Controlled Inorder with a Stack
mediumHow 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.
Basic Calculator: Stack-Based Expression Evaluation
hardHow to solve LeetCode 224 Basic Calculator using a stack for parentheses. O(n) solution with visual walkthrough.
Basic Calculator II: Stack-Based Operator Precedence
mediumHow to solve LeetCode 227 Basic Calculator II using a stack for operator precedence. O(n) solution with visual walkthrough.
Add Digits: The Digital Root Formula
easyHow to solve LeetCode 258 Add Digits. Reduce a number to a single digit by repeatedly summing its digits, with an O(1) math solution.
Word Ladder II: All Shortest Transformation Paths
hardHow to solve LeetCode 126 Word Ladder II. Use BFS to build a distance map, then DFS backtracking to recover all shortest transformation sequences.
Wildcard Matching: DP with ? and * Patterns
hardHow to solve LeetCode 44 Wildcard Matching with 2D dynamic programming. Handle '?' single-char and '*' multi-char wildcards with a boolean DP table.
Valid Sudoku: Hash Set Validation
mediumHow 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.
Unique Paths II: DP with Obstacles
mediumHow 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.
Unique Binary Search Trees: Catalan Numbers and DP
mediumHow to solve LeetCode 96 Unique Binary Search Trees with bottom-up DP. Visual walkthrough of the Catalan number recurrence and root-splitting strategy.
Unique Binary Search Trees II: Generate All Valid BSTs
mediumHow to solve LeetCode 95 by recursively generating all structurally unique BSTs for values 1 to n. Full walkthrough with visuals.
Triangle: Bottom-Up DP for Minimum Path Sum
mediumHow to solve LeetCode 120 Triangle with bottom-up dynamic programming. Start from the last row, reduce upward, and get O(n) space.
Sum Root to Leaf Numbers: Building Numbers Top-Down
mediumHow 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.
Sudoku Solver: Backtracking with Constraint Checking
hardHow to solve LeetCode 37 Sudoku Solver using backtracking with row, column, and box constraint sets. The classic constraint satisfaction problem on a grid.
Subsets II: Backtracking Without Duplicate Subsets
mediumHow 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.
Sqrt(x): Binary Search for the Integer Square Root
easyHow to solve LeetCode 69 Sqrt(x) using binary search on the answer space. Search for the largest integer whose square fits within x.
Spiral Matrix II: Filling a Matrix in Spiral Order
mediumHow 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.
Simplify Path: Stack-Based Directory Navigation
mediumHow to solve LeetCode 71 Simplify Path using a stack. Split by slash, filter tokens, and rebuild the canonical Unix path.
Search in Rotated Sorted Array II: Handling Duplicates
mediumHow 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.
Search a 2D Matrix: Binary Search on a Flattened Grid
mediumHow 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.
Same Tree: Recursive Structure Comparison
easyHow to solve LeetCode 100 Same Tree by recursively comparing two binary trees in parallel. Visual walkthrough with Python solution.
Rotate List: Circular Linked List Rotation
mediumHow to solve LeetCode 61 Rotate List by making the list circular and breaking it at the right position. Visual walkthrough with Python solution.
Reverse Linked List II: Reverse a Sublist in One Pass
mediumHow 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.
Restore IP Addresses: Backtracking with Constraints
mediumHow 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.
Remove Duplicates from Sorted List: Keep One of Each
easyHow to solve LeetCode 83 Remove Duplicates from Sorted List. Visual walkthrough of in-place linked list deduplication with a single pointer.
Remove Duplicates from Sorted List II: Delete All Duplicated Nodes
mediumHow 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.
Remove Duplicates from Sorted Array II: Allow At Most Two
mediumHow 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.
Recover Binary Search Tree: Find and Fix Two Swapped Nodes
mediumHow to solve LeetCode 99 Recover Binary Search Tree by finding two swapped nodes using inorder traversal violation detection. O(n) time, O(h) space.
Pow(x, n): Fast Exponentiation by Squaring
mediumHow 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.
Populating Next Right Pointers: Level-by-Level Linking
mediumHow 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.
Populating Next Right Pointers II: Handling Non-Perfect Trees
mediumHow 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.
Plus One: Handling Carry in Array Arithmetic
easyHow 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.
Permutations II: Backtracking with Duplicate Handling
mediumHow to solve LeetCode 47 Permutations II using sorted backtracking with a used array and same-level duplicate skipping. Visual recursion tree with pruned branches.
Permutation Sequence: The Factorial Number System
hardHow 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.
Path Sum II: Collecting All Valid Root-to-Leaf Paths
mediumHow 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.
Pascal's Triangle: Row-by-Row Construction
easyHow to solve LeetCode 118 Pascal's Triangle by building each row iteratively. A clean introduction to the neighbor sum pattern.
Pascal's Triangle II: Single Row in O(k) Space
easyHow to solve LeetCode 119 Pascal's Triangle II by building the target row in place with reverse iteration. O(k) time, O(k) space.
Partition List: Two-Pointer Split and Reconnect
mediumHow to solve LeetCode 86 Partition List using dual dummy-headed lists. O(n) time, O(1) space solution with visual walkthrough and building blocks.
Palindrome Partitioning: Backtracking All Valid Splits
mediumHow to solve LeetCode 131 Palindrome Partitioning using backtracking. Try every prefix, check if it is a palindrome, and recurse on the remainder.
Palindrome Partitioning II: Minimum Cuts with DP
hardHow 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.
N-Queens II: Counting Solutions with Backtracking
hardHow to solve LeetCode 52 N-Queens II by counting valid n-queens configurations using backtracking with column and diagonal constraint sets.
Multiply Strings: Grade-School Multiplication
mediumHow 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.
Minimum Depth of Binary Tree: Finding the Nearest Leaf
easyHow 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.
Length of Last Word: Scanning from the Right
easyHow 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.
Largest Rectangle in Histogram: Monotonic Stack
hardHow to solve LeetCode 84 Largest Rectangle in Histogram using a monotonic increasing stack of indices. Visual walkthrough, Python solution, and O(n) complexity analysis.
Jump Game II: Minimum Jumps with Greedy BFS
mediumHow to solve LeetCode 45 Jump Game II in O(n) time and O(1) space using a greedy BFS approach that tracks jump boundaries.
Interleaving String: 2D DP on Two Strings
mediumHow 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.
Insert Interval: Merge on the Fly
mediumHow 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.
First Missing Positive: Cyclic Sort in O(n) Time
hardHow 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.
Distinct Subsequences: 2D DP for Subsequence Counting
hardHow to solve LeetCode 115 Distinct Subsequences with 2D DP. Match/skip recurrence for counting subsequences, explained visually.
Count and Say: Run-Length Encoding Sequence
mediumHow 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.
Convert Sorted List to BST: Finding the Middle with Slow/Fast Pointers
mediumHow to convert a sorted linked list into a height-balanced binary search tree using slow/fast pointers and recursion. LeetCode 109 explained with visuals.
Convert Sorted Array to BST: Divide and Conquer
easyHow to solve LeetCode 108 Convert Sorted Array to Binary Search Tree using divide and conquer. Visual walkthrough of the middle-element recursion approach.
Construct Binary Tree from Inorder and Postorder Traversal
mediumHow 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.
Combinations: Backtracking with a Size Constraint
mediumHow to solve LeetCode 77 Combinations using backtracking with a start index and path length constraint. Recursion tree, pruning, and building blocks explained.
Combination Sum II: Backtracking Without Duplicates
mediumHow to solve LeetCode 40 Combination Sum II using sorted backtracking with same-level duplicate skipping. Visual walkthrough of pruning and deduplication.
Candy: Two-Pass Greedy Distribution
hardHow to solve LeetCode 135 Candy with a two-pass greedy algorithm. Satisfy neighbor constraints from both directions and take the max.
Binary Tree Zigzag Level Order Traversal: BFS with Alternating Direction
mediumHow to solve LeetCode 103 with BFS. Process each level of the tree with a queue, reversing every other level to produce the zigzag order.
Binary Tree Maximum Path Sum: Global Max with Local Returns
hardHow 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.
Binary Tree Level Order Traversal II: Bottom-Up BFS
mediumHow 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.
Binary Tree Inorder Traversal: Left, Root, Right
easyHow to solve LeetCode 94 Binary Tree Inorder Traversal with recursive and iterative stack-based approaches. Visual walkthrough of both solutions.
Best Time to Buy and Sell Stock III: At Most Two Transactions
hardHow 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.
Best Time to Buy and Sell Stock II: Greedy Profit Collection
mediumHow 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.
Balanced Binary Tree: Bottom-Up Height Check
easyHow 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.
Add Binary: Right-to-Left Addition with Carry
easyHow 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.
Zigzag Conversion: Reading a Pattern Row by Row
mediumHow to solve LeetCode 6 Zigzag Conversion. Simulate the zigzag placement row by row using a direction flag, then concatenate the rows.
Swap Nodes in Pairs: Pairwise Linked List Manipulation
mediumHow to solve LeetCode 24 Swap Nodes in Pairs with iterative and recursive approaches. Visual walkthrough of the dummy head and pointer rewiring technique.
Substring with Concatenation of All Words
hardHow 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.
Search Insert Position: Binary Search for the Insertion Point
easyHow to solve LeetCode 35 Search Insert Position using binary search. When the target is missing, the left pointer lands on the exact insertion index.
Roman to Integer: Left-to-Right with Subtraction Rule
easyHow 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.
Reverse Nodes in k-Group: Chunked Linked List Reversal
hardHow 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.
Reverse Integer: Digit Extraction with Overflow Check
mediumHow to solve LeetCode 7 Reverse Integer. Extract digits with mod 10, build the reversed number, and check for 32-bit overflow before each step.
Remove Element: In-Place Array Filtering
easyHow to solve LeetCode 27 Remove Element using a read-write pointer to filter an array in-place. Visual walkthrough, Python solution, and building blocks.
Remove Duplicates from Sorted Array: In-Place with Two Pointers
easyHow to solve LeetCode 26 using a slow/fast two-pointer technique to remove duplicates in-place. Visual walkthrough, Python solution, and building blocks.
Regular Expression Matching: DP with Wildcards
hardHow to solve LeetCode 10 Regular Expression Matching with 2D dynamic programming. Handle '.' and '*' wildcards with a boolean DP table.
Palindrome Number: Half-Reversal Without String Conversion
easyHow 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.
Next Permutation: The Three-Step Algorithm
mediumHow to solve LeetCode 31 Next Permutation in O(n) time and O(1) space. Find the pivot, swap the successor, and reverse the suffix.
Merge Two Sorted Lists: The Fundamental Merge Operation
easyHow 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.
Longest Valid Parentheses: Stack-Based Substring Tracking
hardHow 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.
Longest Common Prefix: Column-by-Column Comparison
easyHow to solve LeetCode 14 Longest Common Prefix. Compare characters column by column across all strings until they diverge.
Integer to Roman: Greedy Value Decomposition
mediumHow to solve LeetCode 12 Integer to Roman using a greedy lookup table. Build the roman numeral by subtracting values from largest to smallest.
Find the Index of the First Occurrence in a String
easyHow 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.
Find First and Last Position: Two Binary Searches
mediumHow 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.
Divide Two Integers: Bit Shifting Without Multiplication
mediumHow 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.
Design Memory Allocator: Contiguous Block Allocation
mediumHow to solve LeetCode 2502. Design a memory allocator that finds the leftmost consecutive free block and supports freeing by ID.
4Sum: Extending Two Pointers to Four Elements
mediumHow 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.
3Sum Closest: Two Pointers with Distance Tracking
mediumHow to solve LeetCode 16 3Sum Closest using sorting and two pointers with distance tracking. O(n^2) time, O(1) space.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Number of Adjacent Elements With the Same Color
mediumHow to solve LeetCode 2672 efficiently. Maintain a running count of adjacent matching pairs instead of rescanning the array after every query.
Word Search II: Trie-Powered Board Search
hardHow 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.
Word Ladder: Shortest Transformation with BFS
hardHow to solve LeetCode 127 Word Ladder. Model words as graph nodes and use BFS to find the shortest transformation sequence.
Rotate Image: In-Place Matrix Rotation
mediumHow to rotate an n x n matrix 90 degrees clockwise in place. The transpose-then-reverse trick explained step by step.
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.
Number of 1 Bits: Counting Set Bits
easyHow to solve LeetCode 191 Number of 1 Bits. Two approaches: bit shifting and the n & (n-1) trick that clears one bit per step.
Maximal Square: DP on a Binary Matrix
mediumHow to solve LeetCode 221 Maximal Square with dynamic programming. Build a DP table where each cell tracks the largest square ending at that corner.
Binary Tree Level Order Traversal: BFS with a Queue
mediumHow to solve LeetCode 102 with BFS. Use a queue to process each level of the tree and collect results layer by layer.
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.
Happy Number: Cycle Detection with a Hash Set
easyHow 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.
Generate Parentheses: Backtracking with Constraints
mediumHow to solve LeetCode 22 Generate Parentheses. Use backtracking with open/close counters to build only valid combinations.
Gas Station: Greedy Circuit Traversal
mediumHow to solve LeetCode 134 Gas Station with a greedy one-pass algorithm. Find the unique starting point to complete a circular route.
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.
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.
Copy List with Random Pointer: Deep Copy with a Hash Map
mediumHow to solve LeetCode 138. Use a hash map to clone a linked list with random pointers in two passes.
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.
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.
Word Break: Dynamic Programming on Strings
mediumHow to solve LeetCode Word Break with DP. Check if a string can be segmented into dictionary words.
Unique Paths: 2D Grid Dynamic Programming
mediumHow to solve LeetCode Unique Paths with 2D DP. The essential grid traversal pattern for interviews.
Task Scheduler: Greedy Frequency Counting
mediumHow to solve LeetCode Task Scheduler with the greedy frame approach. Calculate minimum intervals from the most frequent task.
Symmetric Tree: Mirror Recursion
easyHow to solve LeetCode Symmetric Tree by comparing mirror pairs recursively. Visual walkthrough of the symmetry check.
Surrounded Regions: Border DFS Trick
mediumHow to solve LeetCode Surrounded Regions by protecting border-connected cells with reverse DFS. Think from the edges inward.
Subtree of Another Tree: Recursive Tree Matching
easyHow to solve LeetCode Subtree of Another Tree with recursive comparison. Check every node as a potential root match.
String to Integer (atoi): State Machine Parsing
mediumHow to solve LeetCode String to Integer using a state machine. Handle whitespace, signs, overflow, and edge cases.
Sort Colors: The Dutch National Flag Algorithm
mediumHow to solve LeetCode Sort Colors in one pass with three pointers. The classic partition problem explained visually.
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.
Set Matrix Zeroes: In-Place Matrix Marking
mediumHow to solve LeetCode Set Matrix Zeroes in O(1) space by using the first row and column as markers.
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.
Reorder List: Three Classic Patterns in One Problem
mediumHow to solve LeetCode Reorder List by combining fast-slow, reverse, and merge. Three patterns working together.
Ransom Note: Frequency Counting with Available Supply
easyHow to solve LeetCode Ransom Note by counting available characters. A clean frequency map problem.
Path Sum: Root-to-Leaf Target Check
easyHow to solve LeetCode Path Sum with DFS recursion. Subtract each node value and check if you reach zero at a leaf.
Partition Equal Subset Sum: 0/1 Knapsack in Disguise
mediumHow to solve LeetCode Partition Equal Subset Sum with DP. Recognize the 0/1 knapsack pattern hiding in a partition problem.
Palindrome Linked List: Fast-Slow + Reverse
easyHow to solve LeetCode Palindrome Linked List in O(1) space. Find middle, reverse second half, compare.
Pacific Atlantic Water Flow: Reverse DFS from Edges
mediumHow to solve LeetCode Pacific Atlantic Water Flow using reverse DFS from ocean borders. Think backwards to find the answer.
N-Queens: Constraint Backtracking
hardHow to solve LeetCode N-Queens using backtracking with column and diagonal constraints. The classic constraint satisfaction problem.
Minimum Path Sum: Grid DP from Top-Left to Bottom-Right
mediumHow to solve LeetCode Minimum Path Sum with 2D DP. Fill the grid cell by cell taking the minimum from above or left.
Merge K Sorted Lists: Min Heap Merge
hardHow to solve LeetCode Merge K Sorted Lists using a min heap. Efficiently pick the smallest element across k lists.
Meeting Rooms II: Min Heap Scheduling
mediumHow to solve LeetCode Meeting Rooms II with a min heap. Track the earliest ending meeting to reuse rooms.
Maximum Subarray: Kadane's Algorithm
mediumHow to solve LeetCode Maximum Subarray in O(n) with Kadane's algorithm. The key decision: extend or restart.
Maximum Product Subarray: Track Min and Max
mediumHow to solve LeetCode Maximum Product Subarray. Why you need to track both minimum and maximum because negatives flip signs.
Maximal Rectangle: Histogram Stack on Every Row
hardHow to solve LeetCode Maximal Rectangle by building histograms row by row and applying the largest rectangle in histogram technique.
Longest Repeating Character Replacement: Sliding Window
mediumHow to solve LeetCode Longest Repeating Character Replacement with sliding window. The window_size - max_freq trick.
Longest Palindrome: Greedy Character Pairing
easyHow to solve LeetCode Longest Palindrome (409) by counting character pairs. A greedy frequency problem.
Longest Common Subsequence: 2D String DP
mediumHow to solve LeetCode Longest Common Subsequence with a 2D DP table. The fundamental two-string comparison pattern.
Linked List Cycle II: Find the Cycle Start
mediumHow to solve LeetCode Linked List Cycle II. Find where the cycle begins using Floyd's algorithm phase two.
Koko Eating Bananas: Binary Search on the Answer
mediumHow to solve LeetCode Koko Eating Bananas by binary searching the eating speed. The classic search-on-answer pattern.
Implement Trie: The Prefix Tree
mediumHow to build a Trie from scratch for LeetCode. Insert, search, and startsWith in O(m) time.
Implement Queue Using Stacks: The Lazy Transfer Trick
easyHow to solve LeetCode Implement Queue Using Stacks with amortized O(1) operations. Two stacks make a queue.
Flatten Binary Tree to Linked List: In-Place Preorder
mediumHow to solve LeetCode Flatten Binary Tree to Linked List in O(1) space. Rewire the tree in preorder without extra storage.
Find Peak Element: Binary Search on Slope
mediumHow to solve LeetCode Find Peak Element in O(log n). Use binary search by following the ascending slope.
Find Minimum in Rotated Sorted Array
mediumHow to solve LeetCode Find Minimum in Rotated Sorted Array in O(log n). Binary search on the inflection point.
Evaluate Reverse Polish Notation: Stack Calculator
mediumHow to solve LeetCode Evaluate Reverse Polish Notation with a stack. Push numbers, pop for operators.
Edit Distance: The Classic 2D String DP
mediumHow to solve LeetCode Edit Distance with 2D DP. Insert, delete, and replace operations explained visually.
Diameter of Binary Tree: Global Max with Local Returns
easyHow to solve LeetCode Diameter of Binary Tree. The key trick: return depth to parent, update diameter globally.
Design Add and Search Words: Trie with Wildcards
mediumHow to solve LeetCode Add and Search Words with a trie and DFS for wildcard dots. Extend the basic trie with backtracking.
Trees: Binary Trees, BSTs, and Traversals
Understanding binary trees and BSTs. Traversal orders, recursion patterns, and the essential tree interview problems.
Stacks: Last In, First Out
Understanding stacks from push/pop operations to real-world uses. Plus every stack interview problem you need to know.
Stacks and Queues: LIFO vs FIFO
Understanding stacks and queues. How they differ, when to use each, and the key interview problems for both.
Queues: First In, First Out
Understanding queues from enqueue/dequeue to BFS. How FIFO ordering powers level-by-level processing and graph traversal.
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.
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.
Arrays: The Foundation of Everything
Understanding arrays from memory layout to time complexities. Plus the essential array problems every developer should know.
Construct Binary Tree from Preorder and Inorder
mediumHow to solve LeetCode Construct Binary Tree from Preorder and Inorder Traversal. Split arrays recursively to rebuild the tree.
Clone Graph: DFS with a Hash Map
mediumHow to solve LeetCode Clone Graph using DFS and a hash map to track visited/cloned nodes. Deep copy a graph in O(n).
Alien Dictionary: Topological Sort on Characters
hardHow to solve LeetCode Alien Dictionary by extracting ordering from word pairs and running topological sort.
Add Two Numbers: Linked List Digit Addition
mediumHow to solve LeetCode Add Two Numbers by traversing two linked lists with carry. The fundamental linked list builder pattern.
XOR Cancellation: How Pairs Disappear Like Magic
easyUnderstanding XOR from the ground up. How the cancellation property solves Single Number in O(n) time and O(1) space.
Search in Rotated Sorted Array: Modified Binary Search
mediumHow to solve LeetCode Search in Rotated Sorted Array in O(log n). Identify the sorted half and search smartly.
Remove Nth Node From End: Two Pointer Gap Technique
mediumHow to solve LeetCode Remove Nth Node From End in one pass using the two-pointer gap technique.
Longest Increasing Subsequence: DP and Binary Search
mediumHow to solve LeetCode LIS in O(n^2) with DP or O(n log n) with patience sorting. Both approaches explained.
Letter Combinations of a Phone Number: Backtracking
mediumHow to solve LeetCode Letter Combinations using backtracking. Build all combinations from digit-to-letter mapping.
Combination Sum: Backtracking with Reuse
mediumHow to solve LeetCode Combination Sum using backtracking with unlimited element reuse. Pruning explained visually.
Word Search: Grid Backtracking
mediumHow to solve LeetCode Word Search using DFS backtracking on a grid. The choose-explore-unchoose pattern.
Validate BST: Range Checking vs Inorder
mediumHow to solve LeetCode Validate BST with range bounds or inorder traversal. Two approaches compared.
Valid Palindrome: Two Pointer String Check
easyHow to solve LeetCode Valid Palindrome with two pointers. Handle non-alphanumeric characters cleanly.
Top K Frequent Elements: Bucket Sort Trick
mediumHow to solve LeetCode Top K Frequent Elements in O(n) with bucket sort. Faster than heap for this problem.
Subsets: Backtracking Decision Tree
mediumHow to solve LeetCode Subsets using backtracking. Generate all 2^n subsets with the include/exclude pattern.
Spiral Matrix: Layer by Layer Traversal
mediumHow to solve LeetCode Spiral Matrix with boundary tracking. The four-direction traversal pattern explained.
Serialize and Deserialize Binary Tree
hardHow to solve LeetCode Serialize/Deserialize Binary Tree with preorder DFS. Convert trees to strings and back.
Permutations: Complete Backtracking Guide
mediumHow to solve LeetCode Permutations using backtracking. Build all n! arrangements with the swap technique.
Palindromic Substrings: Expand Around Center
mediumHow to solve LeetCode Palindromic Substrings in O(n^2) using expand-from-center. Count all palindromes efficiently.
Min Stack: O(1) Minimum with Two Stacks
mediumHow to implement LeetCode Min Stack with O(1) push, pop, and getMin. The auxiliary stack trick explained.
Merge Intervals: Sort and Sweep
mediumHow to solve LeetCode Merge Intervals by sorting and merging overlapping ranges. The essential interval pattern.
Median of Two Sorted Arrays: Binary Search on Partitions
hardHow to solve LeetCode Median of Two Sorted Arrays in O(log(min(m,n))). The hardest binary search problem explained.
LRU Cache: Hash Map + Doubly Linked List
mediumHow to implement LeetCode LRU Cache with O(1) get and put. The classic design problem explained visually.
Lowest Common Ancestor: Post-Order Tree Logic
mediumHow to solve LeetCode Lowest Common Ancestor using post-order DFS. The elegant recursive solution explained.
Longest Palindromic Substring: Expand From Center
mediumHow to solve LeetCode Longest Palindromic Substring in O(n^2). The expand-from-center technique explained visually.
Kth Largest Element: Heap vs Quickselect
mediumHow to solve LeetCode Kth Largest Element with a min-heap or quickselect. Two O(n) approaches compared.
House Robber: DP With a Twist
mediumHow to solve LeetCode House Robber with dynamic programming. The rob-or-skip decision explained visually.
Decode Ways: DP String Decoding
mediumHow to solve LeetCode Decode Ways with dynamic programming. Handle zeros and two-digit codes step by step.
Course Schedule: Cycle Detection with DFS
mediumHow to solve LeetCode Course Schedule using topological sort and cycle detection. Graph DFS explained visually.
Coin Change: Classic Dynamic Programming
mediumHow to solve LeetCode Coin Change with bottom-up DP. Visual table walkthrough for the unbounded knapsack pattern.
Valid Anagram: Frequency Counting Pattern
easyHow to solve LeetCode Valid Anagram using character frequency counting. Sort vs hash map approaches compared.
3Sum: Sorting Plus Two Pointers
mediumHow to solve LeetCode 3Sum in O(n^2) using sort and converging pointers. Handle duplicates cleanly.
Rotate Array: The Triple Reverse Trick
mediumHow to solve LeetCode Rotate Array in O(n) time and O(1) space using three reversals.
Reverse Linked List: The Pointer Swap Technique
easyHow to solve LeetCode Reverse Linked List iteratively and recursively. Visual step-by-step pointer reversal guide.
Product of Array Except Self: Two-Pass Prefix/Suffix
mediumHow to solve LeetCode Product of Array Except Self in O(n) without division. Prefix and suffix product walkthrough.
Number of Islands: Grid DFS Pattern
mediumHow to solve LeetCode Number of Islands using DFS flood fill. The essential grid traversal pattern explained.
Minimum Window Substring: Advanced Sliding Window
hardHow to solve LeetCode Minimum Window Substring with sliding window and frequency counting. O(n) solution.
Merge Sorted Array: The Backwards Trick
easyHow to solve LeetCode Merge Sorted Array in-place by filling from the end. O(n) two-pointer solution explained.
Maximum Depth of Binary Tree: Recursion Made Simple
easyHow to solve LeetCode Maximum Depth of Binary Tree with DFS recursion. Visual tree traversal walkthrough.
Majority Element: Boyer-Moore Voting Algorithm
easyHow to solve LeetCode Majority Element in O(n) time and O(1) space with the Boyer-Moore voting algorithm.
Longest Substring Without Repeating Characters
mediumHow to solve LeetCode Longest Substring Without Repeating Characters using sliding window and a set. O(n) solution.
Longest Consecutive Sequence: The Set Trick
mediumHow to solve LeetCode Longest Consecutive Sequence in O(n) using a set. Why sorting is not needed.
Linked List Cycle: Floyd's Tortoise and Hare
easyHow to detect a cycle in a linked list using O(1) space. Floyd's algorithm explained with visuals.
Jump Game: Greedy Reachability
mediumHow to solve LeetCode Jump Game in O(n) using greedy farthest-reach tracking. No DP needed.
Invert Binary Tree: The Famous Three-Line Solution
easyHow to solve LeetCode Invert Binary Tree with recursion. The problem that started a meme.
Group Anagrams: Hash Map Grouping Pattern
mediumHow to solve LeetCode Group Anagrams in O(n*k) using sorted keys. Step-by-step visual walkthrough.
Daily Temperatures: Monotonic Stack Explained
mediumHow to solve LeetCode Daily Temperatures using a monotonic stack. Visual walkthrough of the next-greater-element pattern.
Container With Most Water: Two Pointer Greedy
mediumHow to solve LeetCode Container With Most Water in O(n) using two pointers. Why moving the shorter side is optimal.
Climbing Stairs: Your First Dynamic Programming Problem
easyHow to solve LeetCode Climbing Stairs with DP in O(n) time and O(1) space. The perfect intro to dynamic programming.
Binary Search (LeetCode 704): The Foundation
easyHow to implement binary search correctly. Avoid off-by-one errors with this clear visual walkthrough.
Valid Parentheses: Stack Pattern Explained
easyHow to solve LeetCode Valid Parentheses using a stack. Visual step-by-step walkthrough with Python code.
Two Sum: The Classic Interview Starter
easyHow to solve LeetCode Two Sum in O(n) using a hash map complement lookup. Step-by-step walkthrough with visuals.
Trapping Rain Water: Two Pointer Approach
hardHow to solve LeetCode Trapping Rain Water in O(n) time and O(1) space using two pointers. Visual step-by-step guide.
Contains Duplicate: Three Solutions Compared
easyHow to solve LeetCode Contains Duplicate using a set, sorting, or brute force. O(n) optimal solution explained.
Best Time to Buy and Sell Stock: One Pass Solution
easyHow to solve LeetCode Best Time to Buy and Sell Stock in O(n) by tracking the running minimum. Visual walkthrough.
Binary Search: More Than Finding a Number
Learn binary search with visual walkthroughs, Python code, and the 'search on the answer space' variant that unlocks a whole class of interview problems.
Stack Patterns: Matching, Nesting, and More
Master stack patterns for coding interviews: bracket matching, monotonic stacks, and state save/restore. Visual walkthroughs with Python examples.
Hash Map Patterns for Coding Interviews
Master the three core hash map patterns for coding interviews: frequency counting, complement lookup, and grouping. Python examples with O(1) lookups.
The Two Pointers Pattern: A Complete Guide
Master the two pointers technique for sorted array and linked list problems in O(n) time. Visual walkthrough with Python code and common variations.
The Sliding Window Pattern: A Complete Guide
Learn the sliding window technique for solving subarray and substring problems in O(n) time. Step-by-step visual walkthrough with Python code examples.