Skip to content
On this page
Leetcode

🏆 Curated solutions to Leetcode problems in multiple languages to ace the Coding Interviews.

🔍 Press Ctrl+F or +F to search for a specific problem

Array

#SolutionTagsDifficultyRemark
0001Two SumArray, Hash Table
0004Median of Two Sorted ArraysArray, Binary Search, Divide & Conquer
0026Remove DuplicatesArray, Two Pointers
0027Remove ElementArray, Two Pointers
0035Search Insert PositionArray, BS
0037Sudoku SolverArray, Backtracking, Matrix
0041First Missing PositiveArray, Hash Table
0042Trapping Rain WaterArray, Two Pointers, Dynamic Programming, Stack, Monotonic Stack
0048Rotate ImageArray, Math, Matrix
0051N-QueensArray, Backtracking
0053Maximum SubarrayArray, Divide and Conquer, DP
0055Jump GameArray, Dynamic Programming, Greedy
0066Plus OneArray, Math
0074Search a 2D MatrixArray, Binary Search, Matrix
0075Sort ColorsArray, Two Pointers, Sorting
0078SubsetsArray, Backtracking, Bit Manip
0088Merge Sorted ArrayArray, Two Pointers, Sorting
0106Construct Binary Tree from Inorder and Postorder TraversalArray, Hash Table, Divide and Conquer, Tree, Binary Tree
0108Convert Sorted Array to Binary Search TreeArray, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0118Pascal's TriangleArray, DP
0119Pascal's Triangle IIArray, DP
0121Best Time to Buy and Sell StockArray, DP
0122Best Time to Buy and Sell Stock IIArray, Dynamic Programming, Greedy
0136Single NumberArray, Bit Manip
0169Majority ElementArray, Hash Table, Divide and Conquer, Sorting, Counting
0200Number of IslandsArray, Depth-First Search, Breadth-First Search, Union Find, Matrix
0217Contains DuplicateArray, Hash Table, Sorting
0219Contains Duplicate IIArray, Hash Table, Sliding Window
0228Summary RangesArray
0268Missing NumberArray, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
0283Move ZeroesArray, Two Pointers
0300Longest Increasing SubsequenceArray, Binary Search, DP
0322Coin ChangeArray, Dynamic Programming, BFS
0349Intersection of Two ArraysArray, Hash Table, Two Pointers, Binary Search, Sorting
0350Intersection of Two Arrays IIArray, Hash Table, Two Pointers, Binary Search, Sorting
0414Third Maximum NumberArray, Sorting
0442Find All DuplicatesArray, Hash Table
0448Find All Numbers Disappeared in an ArrayArray, Hash Table
0463Island PerimeterArray, Depth-First Search, Breadth-First Search, Matrix
0485Max Consecutive OnesArray
0498Diagonal TraverseArray, Matrix, Simulation
0502IPOArray, Greedy, Sorting, Heap (Priority Queue)
0506Relative RanksArray, Sorting, Heap
0518Coin Change 2Array, DP
0540Single Element in a Sorted ArrayArray, BS
0605Can Place FlowersArray, Greedy
0695Max Area of IslandArray, Depth-First Search, Breadth-First Search, Union Find, Matrix
0704Binary SearchArray, Binary Search
0739Daily TemperaturesArray, Stack, Monotonic Stack
0875Koko Eating BananasArray, BS
0888Fair Candy SwapArray, Hash Table, Binary Search, Sorting
0912Sort an ArrayArray, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort
0944Delete Columns to Make SortedArray, String
0997Find the Town JudgeArray, Hash Table, Graph
1011Capacity To Ship Packages Within D DaysArray, BS
1029Two City SchedulingArray, Greedy, Sorting
1232Check If It Is a Straight LineArray, Math, Geometry
1345Jump Game IVArray, Hash Table, Breadth-First Search
1431Kids With the Greatest Number of CandiesArray
1472Design Browser HistoryArray, Linked List, Stack, Design, Doubly-Linked List, Data Stream
1480Running Sum of 1d ArrayArray, Prefix Sum
1491Average Salary Excluding the Minimum and MaximumArray, Sorting
1498Number of Subsequences That Satisfy the Given Sum ConditionArray, Two Pointers, Binary Search, Sorting
1512Number of Good PairsArray, Hash Table, Math, Counting
1537Get the Maximum ScoreArray, Two Pointer, Dynamic Programming, Greedy
1539Kth Missing Positive NumberArray, BS
1580Shuffle the ArrayArray
1672Richest Customer WealthArray, Matrix
1920Build Array from PermutationArray, Simulation
1929Concatenation of ArrayArray
2011Final Value of Variable After Performing OperationsArray, String, Simulation
2114Maximum Number of Words Found in SentencesArray, String
2176Count Equal and Divisible Pairs in an ArrayArray
2187Minimum Time to Complete TripsArray, BS
2348Number of Zero-Filled SubarraysArray, Math
2444Count Subarrays With Fixed BoundsArray, Queue, Sliding Window, Monotonic Queue
2551Put Marbles in BagsArray, Greedy, Sorting, Heap (Priority Queue)
2574Left and Right Sum DifferencesArray, Prefix Sum

String

#SolutionTagsDifficultyRemark
0013Roman to IntegerString, Math, Hash Table
0014Longest Common PrefixString
0020Valid ParenthesesString, ST
0022Generate ParenthesesString, Dynamic Programming, Backtracking
0028Find the Index of the First Occurrence in a StringTwo Pointers, String, String Matching
0058Length of Last WordString
0067Add BinaryMath, String, Bit Manipulation, Simulation
0072Edit DistanceString, DP
0125Valid PalindromeTwo Pointers, String
0205Isomorphic StringsHash Table, String
0211Design Add and Search Words Data StructureString, Depth-First Search, Design, Trie
0242Valid AnagramHash Table, String, Sorting
0257Binary Tree PathsString, Backtracking, Tree, Depth-First Search, Binary Tree
0290Word PatternHash Table, String
0344Reverse StringTwo Pointers, String, Recursion
0345Reverse Vowels of a StringTwo Pointers, String
0383Ransom NoteHash Table, String, Counting
0387First Unique Character in a StringHash Table, String, Queue, Counting
0389Find the DifferenceHash Table, String, Bit Manipulation, Sorting
0392Is SubsequenceTwo Pointers, String, DP
0412Fizz BuzzMath, String, Simulation
0434Number of Segments in a StringString
0438Find All Anagrams in a StringHash Table, String, Sliding Window
0443String CompressionTwo Pointers, String
0482License Key FormattingString
0516Longest Palindromic SubsequenceString, DP
0541Reverse String IITwo Pointers, String
0771Jewels and StonesString, Hashtable
0944Delete Columns to Make SortedArray, String
1047Remove All Adjacent Duplicates In StringString, Stack
1092Shortest Common SupersequenceString, DP
1108Defanging an IP AddressString
1143Longest Common SubsequenceString, DP
1461Check If a String Contains All Binary Codes of Size KString, Hash Table, Bit Manipulation
1689Partitioning Into Minimum Number Of Deci-Binary NumbersString, Greedy
1957Delete Characters to Make Fancy StringString
2011Final Value of Variable After Performing OperationsArray, String, Simulation
2114Maximum Number of Words Found in SentencesArray, String

Hash Table

#SolutionTagsDifficultyRemark
0001Two SumArray, Hash Table
0013Roman to IntegerString, Math, Hash Table
0041First Missing PositiveArray, Hash Table
0106Construct Binary Tree from Inorder and Postorder TraversalArray, Hash Table, Divide and Conquer, Tree, Binary Tree
0141Linked List CycleHash Table, Linked List, 2P
0142Linked List Cycle IIHash Table, Linked List, 2P
0160Intersection of Two Linked ListsHash Table, Linked List, 2P
0169Majority ElementArray, Hash Table, Divide and Conquer, Sorting, Counting
0202Happy NumberHash Table, Math, 2P
0205Isomorphic StringsHash Table, String
0217Contains DuplicateArray, Hash Table, Sorting
0219Contains Duplicate IIArray, Hash Table, Sliding Window
0242Valid AnagramHash Table, String, Sorting
0268Missing NumberArray, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
0290Word PatternHash Table, String
0349Intersection of Two ArraysArray, Hash Table, Two Pointers, Binary Search, Sorting
0350Intersection of Two Arrays IIArray, Hash Table, Two Pointers, Binary Search, Sorting
0383Ransom NoteHash Table, String, Counting
0387First Unique Character in a StringHash Table, String, Queue, Counting
0389Find the DifferenceHash Table, String, Bit Manipulation, Sorting
0438Find All Anagrams in a StringHash Table, String, Sliding Window
0442Find All DuplicatesArray, Hash Table
0448Find All Numbers Disappeared in an ArrayArray, Hash Table
0652Find Duplicate SubtreesHash Table, Tree, Depth-First Search, Binary Tree
0653Two Sum IV - Input is a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0888Fair Candy SwapArray, Hash Table, Binary Search, Sorting
0771Jewels and StonesString, Hashtable
0997Find the Town JudgeArray, Hash Table, Graph
1345Jump Game IVArray, Hash Table, Breadth-First Search
1512Number of Good PairsArray, Hash Table, Math, Counting

Dynamic Programming

#SolutionTagsDifficultyRemark
0022Generate ParenthesesString, Dynamic Programming, Backtracking
0042Trapping Rain WaterArray, Two Pointers, Dynamic Programming, Stack, Monotonic Stack
0053Maximum SubarrayArray, Divide and Conquer, DP
0055Jump GameArray, Dynamic Programming, Greedy
0070Climbing StairsMath, Dynamic Programming, Memoization
0072Edit DistanceString, DP
0118Pascal's TriangleArray, DP
0119Pascal's Triangle IIArray, DP
0121Best Time to Buy and Sell StockArray, DP
0122Best Time to Buy and Sell Stock IIArray, Dynamic Programming, Greedy
0279Perfect SquaresMath, Dynamic Programming, Breadth-First Search
0300Longest Increasing SubsequenceArray, Binary Search, DP
0322Coin ChangeArray, Dynamic Programming, BFS
0337House Robber IIIDynamic Programming, Tree, Depth First Search, Binary Tree
0338Counting BitsDynamic Programming, Bit Manip
0392Is SubsequenceTwo Pointers, String, DP
0509Fibonacci NumberMath, Recursion, Dynamic Programming, Memoization
0516Longest Palindromic SubsequenceString, DP
0518Coin Change 2Array, DP
1092Shortest Common SupersequenceString, DP
1143Longest Common SubsequenceString, DP
1537Get the Maximum ScoreArray, Two Pointer, Dynamic Programming, Greedy

Math

#SolutionTagsDifficultyRemark
0002Add Two NumbersLinked List, Math, Recursion
0007Reverse IntegerMath
0009Palindrome NumberMath
0013Roman to IntegerString, Math, Hash Table
0048Rotate ImageArray, Math, Matrix
0066Plus OneArray, Math
0067Add BinaryMath, String, Bit Manipulation, Simulation
0069Sqrt(x)Math, BS
0070Climbing StairsMath, Dynamic Programming, Memorization
0172Factorial Trailiing ZeroesMath
0202Happy NumberHash Table, Math, 2P
0231Power of TwoMath, Bit Manipulation, Recursion
0258Add DigitsMath, Simulation, Number Theory
0263Ugly NumberMath
0268Missing NumberArray, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
0279Perfect SquaresMath, Dynamic Programming, Breadth-First Search
0292Nim GameMath, Brainteaser, Game Theory
0326Power of ThreeMath, Recursion
0342Power of FourMath, Bit Manipulation, Recursion
0367Valid Perfect SquareMath, Binary Search
0382Linked List Random NodeLinked List, Math, Reservoir Sampling, Randomized
0412Fizz BuzzMath, String, Simulation
0441Arranging CoinsMath, BS
0445Add Two Numbers IILinked List, Math, Stack
0492Construct the RectangleMath
0504Base 7Math
0507Perfect NumberMath
0509Fibonacci NumberMath, Recursion, Dynamic Programming, Memoization
1232Check If It Is a Straight LineArray, Math, Geometry
1512Number of Good PairsArray, Hash Table, Math, Counting
1630Count Odd Numbers in an Interval RangeMath
2160Minimum Sum of Four Digit Number After Splitting DigitsMath, Greedy, Sorting
2235Add Two IntegersMath
2348Number of Zero-Filled SubarraysArray, Math
2396Strictly Palindromic NumberMath, Two Pointers, Brainteaser
2413Smallest Even MultipleMath, Number Theory
2427Number of Common FactorsMath, Enumeration, Number Theory
2469Convert the TemperatureMath

Sorting

#SolutionTagsDifficultyRemark
0075Sort ColorsArray, Two Pointers, Sorting
0088Merge Sorted ArrayArray, Two Pointers, Sorting
0169Majority ElementArray, Hash Table, Divide and Conquer, Sorting, Counting
0217Contains DuplicateArray, Hash Table, Sorting
0242Valid AnagramHash Table, String, Sorting
0268Missing NumberArray, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
0349Intersection of Two ArraysArray, Hash Table, Two Pointers, Binary Search, Sorting
0350Intersection of Two Arrays IIArray, Hash Table, Two Pointers, Binary Search, Sorting
0389Find the DifferenceHash Table, String, Bit Manipulation, Sorting
0414Third Maximum NumberArray, Sorting
0502IPOArray, Greedy, Sorting, Heap (Priority Queue)
0506Relative RanksArray, Sorting, Heap
0888Fair Candy SwapArray, Hash Table, Binary Search, Sorting
0912Sort an ArrayArray, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort
1029Two City SchedulingArray, Greedy, Sorting
1498Number of Subsequences That Satisfy the Given Sum ConditionArray, Two Pointers, Binary Search, Sorting
1491Average Salary Excluding the Minimum and MaximumArray, Sorting
2160Minimum Sum of Four Digit Number After Splitting DigitsMath, Greedy, Sorting
2551Put Marbles in BagsArray, Greedy, Sorting, Heap (Priority Queue)
#SolutionTagsDifficultyRemark
0100Same TreeTree, Depth First Search, Breadth First Search, Binary Tree
0104Maximum Depth of Binary TreeTree, Breadth First Search, Depth First Search, Binary Tree
0110Balanced Binary TreeTree, Depth First Search, Binary Tree
0111Minimum Depth of Binary TreeTree, Depth First Search, Breadth First Search, Binary Tree
0144Binary Tree Preorder TraversalStack, Tree, Depth First Search, Binary Tree
0145Binary Tree Postorder TraversalStack, Tree, Depth First Search, Binary Tree
0199Binary Tree Right Side ViewTree, Depth First Search, Breadth First Search, Binary Tree
0222Count Complete Tree NodesBinary Search, Tree, Depth First Search, Binary Tree
0230Kth Smallest Element in a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0337House Robber IIIDynamic Programming, Tree, Depth First Search, Binary Tree
0543Diameter of Binary TreeTree, Depth First Search, Binary Tree
0653Two Sum IV - Input is a BST Tree, Depth First Search, Binary Search Tree, Binary Tree

Greedy

#SolutionTagsDifficultyRemark
0055Jump GameArray, Dynamic Programming, Greedy
0094Binary Tree Inorder TraversalStack, Tree, Depth First Search, Binary Tree
0098Validate Binary Search TreeTree, Depth First Search, Binary Search Tree, Binary Tree
0122Best Time to Buy and Sell Stock IIArray, Dynamic Programming, Greedy
0502IPOArray, Greedy, Sorting, Heap (Priority Queue)
0605Can Place FlowersArray, Greedy
1029Two City SchedulingArray, Greedy, Sorting
1537Get the Maximum ScoreArray, Two Pointer, Dynamic Programming, Greedy
1689Partitioning Into Minimum Number Of Deci-Binary NumbersString, Greedy
2160Minimum Sum of Four Digit Number After Splitting DigitsMath, Greedy, Sorting
2551Put Marbles in BagsArray, Greedy, Sorting, Heap (Priority Queue)

Database

#SolutionTagsDifficultyRemark
#SolutionTagsDifficultyRemark
0100Same TreeTree, Depth First Search, Breadth First Search, Binary Tree
0103Binary Tree Zigzag Level Order TraversalTree, Breadth First Search, Binary Tree
0104Maximum Depth of Binary TreeTree, Breadth First Search, Depth First Search, Binary Tree
0111Minimum Depth of Binary TreeTree, Depth First Search, Breadth First Search, Binary Tree
0199Binary Tree Right Side ViewTree, Depth First Search, Breadth First Search, Binary Tree
0230Kth Smallest Element in a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0322Coin ChangeArray, Dynamic Programming, BFS
0653Two Sum IV - Input is a BST Tree, Depth First Search, Binary Search Tree, Binary Tree

Tree

#SolutionTagsDifficultyRemark
0094Binary Tree Inorder TraversalStack, Tree, Depth First Search, Binary Tree
0098Validate Binary Search TreeTree, Depth First Search, Binary Search Tree, Binary Tree
0100Same TreeTree, Depth First Search, Breadth First Search, Binary Tree
0101Symmetric TreeTree, Depth-First Search, Breadth-First Search, Binary Tree
0103Binary Tree Zigzag Level Order TraversalTree, Breadth First Search, Binary Tree
0104Maximum Depth of Binary TreeTree, Breadth First Search, Depth First Search, Binary Tree
0106Construct Binary Tree from Inorder and Postorder TraversalArray, Hash Table, Divide and Conquer, Tree, Binary Tree
0108Convert Sorted Array to Binary Search TreeArray, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0109Convert Sorted List to Binary Search TreeLinked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0110Balanced Binary TreeTree, Depth First Search, Binary Tree
0111Minimum Depth of Binary TreeTree, Depth First Search, Breadth First Search, Binary Tree
0112Path SumTree, Depth-First Search, Breadth-First Search, Binary Tree
0129Sum Root to Leaf NumbersTree, Depth-First Search, Binary Tree
0144Binary Tree Preorder TraversalStack, Tree, Depth First Search, Binary Tree
0145Binary Tree Postorder TraversalStack, Tree, Depth First Search, Binary Tree
0199Binary Tree Right Side ViewTree, Depth First Search, Breadth First Search, Binary Tree
0222Count Complete Tree NodesBinary Search, Tree, Depth First Search, Binary Tree
0226Invert Binary TreeTree, Depth-First Search, Breadth-First Search, Binary Tree
0230Kth Smallest Element in a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0236Lowest Common Ancestor of a Binary TreeTree, Depth-First Search, Binary Tree
0257Binary Tree PathsString, Backtracking, Tree, Depth-First Search, Binary Tree
0337House Robber IIIDynamic Programming, Tree, Depth First Search, Binary Tree
0404Sum of Left LeavesTree, Depth-First Search, Breadth-First Search, Binary Tree
0530Minimum Absolute Difference in BSTTree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree
0543Diameter of Binary TreeTree, Depth First Search, Binary Tree
0652Find Duplicate SubtreesHash Table, Tree, Depth-First Search, Binary Tree
0653Two Sum IV - Input is a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0799Minimum Distance Between BST NodesTree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree
0958Check Completeness of a Binary TreeTree, Breadth-First Search, Binary Tree
2236Root Equal to Sum of ChildrenTree, Binary Tree
#SolutionTagsDifficultyRemark
0004Median of Two Sorted ArraysArray, Binary Search, Divide & Conquer
0035Search Insert PositionArray, BS
0069Sqrt(x)Math, BS
0074Search a 2D MatrixArray, Binary Search, Matrix
0222Count Complete Tree NodesBinary Search, Tree, Depth First Search, Binary Tree
0268Missing NumberArray, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
0278First Bad VersionBinary Search, Interactive
0300Longest Increasing SubsequenceArray, Binary Search, DP
0349Intersection of Two ArraysArray, Hash Table, Two Pointers, Binary Search, Sorting
0350Intersection of Two Arrays IIArray, Hash Table, Two Pointers, Binary Search, Sorting
0367Valid Perfect SquareMath, Binary Search
0374Guess Number Higher or LowerBinary Search, Interactive
0441Arranging CoinsMath, BS
0540Single Element in a Sorted ArrayArray, BS
0704Binary SearchArray, Binary Search
0875Koko Eating BananasArray, BS
1011Capacity To Ship Packages Within D DaysArray, BS
1498Number of Subsequences That Satisfy the Given Sum ConditionArray, Two Pointers, Binary Search, Sorting
0888Fair Candy SwapArray, Hash Table, Binary Search, Sorting
1539Kth Missing Positive NumberArray, BS
2187Minimum Time to Complete TripsArray, BS

Matrix

#SolutionTagsDifficultyRemark
0037Sudoku SolverArray, Backtracking, Matrix
0048Rotate ImageArray, Math, Matrix
0074Search a 2D MatrixArray, Binary Search, Matrix
0200Number of IslandsArray, Depth-First Search, Breadth-First Search, Union Find, Matrix
0463Island PerimeterArray, Depth-First Search, Breadth-First Search, Matrix
0498Diagonal TraverseArray, Matrix, Simulation
0695Max Area of IslandArray, Depth-First Search, Breadth-First Search, Union Find, Matrix
1672Richest Customer WealthArray, Matrix

Binary Tree

#SolutionTagsDifficultyRemark
0094Binary Tree Inorder TraversalStack, Tree, Depth First Search, Binary Tree
0098Validate Binary Search TreeTree, Depth First Search, Binary Search Tree, Binary Tree
0100Same TreeTree, Depth First Search, Breadth First Search, Binary Tree
0101Symmetric TreeTree, Depth-First Search, Breadth-First Search, Binary Tree
0103Binary Tree Zigzag Level Order TraversalTree, Breadth First Search, Binary Tree
0104Maximum Depth of Binary TreeTree, Breadth First Search, Depth First Search, Binary Tree
0106Construct Binary Tree from Inorder and Postorder TraversalArray, Hash Table, Divide and Conquer, Tree, Binary Tree
0108Convert Sorted Array to Binary Search TreeArray, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0109Convert Sorted List to Binary Search TreeLinked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0110Balanced Binary TreeTree, Depth First Search, Binary Tree
0111Minimum Depth of Binary TreeTree, Depth First Search, Breadth First Search, Binary Tree
0112Path SumTree, Depth-First Search, Breadth-First Search, Binary Tree
0129Sum Root to Leaf NumbersTree, Depth-First Search, Binary Tree
0144Binary Tree Preorder TraversalStack, Tree, Depth First Search, Binary Tree
0145Binary Tree Postorder TraversalStack, Tree, Depth First Search, Binary Tree
0199Binary Tree Right Side ViewTree, Depth First Search, Breadth First Search, Binary Tree
0222Count Complete Tree NodesBinary Search, Tree, Depth First Search, Binary Tree
0226Invert Binary TreeTree, Depth-First Search, Breadth-First Search, Binary Tree
0230Kth Smallest Element in a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0236Lowest Common Ancestor of a Binary TreeTree, Depth-First Search, Binary Tree
0257Binary Tree PathsString, Backtracking, Tree, Depth-First Search, Binary Tree
0337House Robber IIIDynamic Programming, Tree, Depth First Search, Binary Tree
0404Sum of Left LeavesTree, Depth-First Search, Breadth-First Search, Binary Tree
0530Minimum Absolute Difference in BSTTree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree
0543Diameter of Binary TreeTree, Depth First Search, Binary Tree
0652Find Duplicate SubtreesHash Table, Tree, Depth-First Search, Binary Tree
0653Two Sum IV - Input is a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0799Minimum Distance Between BST NodesTree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree
0958Check Completeness of a Binary TreeTree, Breadth-First Search, Binary Tree
2236Root Equal to Sum of ChildrenTree, Binary Tree

Two Pointers

#SolutionTagsDifficultyRemark
0004Median of Two Sorted ArraysArray, Binary Search, Divide & Conquer
0027Remove ElementArray, Two Pointers
0028Find the Index of the First Occurrence in a StringTwo Pointers, String, String Matching
0042Trapping Rain WaterArray, Two Pointers, Dynamic Programming, Stack, Monotonic Stack
0061Rotate ListLinked List, Two Pointers
0075Sort ColorsArray, Two Pointers, Sorting
0088Merge Sorted ArrayArray, Two Pointers, Sorting
0125Valid PalindromeTwo Pointers, String
0141Linked List CycleHash Table, Linked List, 2P
0142Linked List Cycle IIHash Table, Linked List, 2P
0160Intersection of Two Linked ListsHash Table, Linked List, 2P
0202Happy NumberHash Table, Math, 2P
0234Palindrome Linked ListLinked List, Two Pointers, Stack, Recursion
0283Move ZeroesArray, Two Pointers
0344Reverse StringTwo Pointers, String, Recursion
0345Reverse Vowels of a StringTwo Pointers, String
0349Intersection of Two ArraysArray, Hash Table, Two Pointers, Binary Search, Sorting
0350Intersection of Two Arrays IIArray, Hash Table, Two Pointers, Binary Search, Sorting
0392Is SubsequenceTwo Pointers, String, DP
0443String CompressionTwo Pointers, String
0541Reverse String IITwo Pointers, String
0653Two Sum IV - Input is a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0876Middle of the Linked ListLinked List, Two Pointers
1498Number of Subsequences That Satisfy the Given Sum ConditionArray, Two Pointers, Binary Search, Sorting
1537Get the Maximum ScoreArray, Two Pointer, Dynamic Programming, Greedy
2396Strictly Palindromic NumberMath, Two Pointers, Brainteaser

Bit Manipulation

#SolutionTagsDifficultyRemark
0067Add BinaryMath, String, Bit Manipulation, Simulation
0078SubsetsArray, Backtracking, Bit Manip
0136Single NumberArray, Bit Manip
0190Reverse BitsDivide and Conquer, Bit Manip
0191Number of 1 BitsDivide & Conquer, Bit Manipulation
0231Power of TwoMath, Bit Manipulation, Recursion
0268Missing NumberArray, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
0338Counting BitsDynamic Programming, Bit Manip
0342Power of FourMath, Bit Manipulation, Recursion
0389Find the DifferenceHash Table, String, Bit Manipulation, Sorting
0401Binary WatchBacktracking, Bit Manip
0461Hamming DistanceBit Manip
0476Number ComplementBit Manip
1461Check If a String Contains All Binary Codes of Size KString, Hash Table, Bit Manipulation

Stack

#SolutionTagsDifficultyRemark
0020Valid ParenthesesString, ST
0042Trapping Rain WaterArray, Two Pointers, Dynamic Programming, Stack, Monotonic Stack
0094Binary Tree Inorder TraversalTree, Stack, Depth First Search, Binary Tree
0144Binary Tree Preorder TraversalStack, Tree, Depth First Search, Binary Tree
0145Binary Tree Postorder TraversalStack, Tree, Depth First Search, Binary Tree
0225Implement Stack using QueuesStack, Design, Q
0232Implement Queue using StacksStack, Design, Q
0234Palindrome Linked ListLinked List, Two Pointers, Stack, Recursion
0445Add Two Numbers IILinked List, Math, Stack
0739Daily TemperaturesArray, Stack, Monotonic Stack
1047Remove All Adjacent Duplicates In StringString, Stack
1472Design Browser HistoryArray, Linked List, Stack, Design, Doubly-Linked List, Data Stream

Design

#SolutionTagsDifficultyRemark
0211Design Add and Search Words Data StructureString, Depth-First Search, Design, Trie
0225Implement Stack using QueuesStack, Design, Q
0232Implement Queue using StacksStack, Design, Q
1472Design Browser HistoryArray, Linked List, Stack, Design, Doubly-Linked List, Data Stream

Heap (Priority Queue)

#SolutionTagsDifficultyRemark
0506Relative RanksArray, Sorting, Heap

Graph

#SolutionTagsDifficultyRemark
0997Find the Town JudgeArray, Hash Table, Graph

Simulation

#SolutionTagsDifficultyRemark
0067Add BinaryMath, String, Bit Manipulation, Simulation
0258Add DigitsMath, Simulation, Number Theory
0412Fizz BuzzMath, String, Simulation
0498Diagonal TraverseArray, Matrix, Simulation
1920Build Array from PermutationArray, Simulation
2011Final Value of Variable After Performing OperationsArray, String, Simulation

Backtracking

#SolutionTagsDifficultyRemark
0022Generate ParenthesesString, Dynamic Programming, Backtracking
0037Sudoku SolverArray, Backtracking, Matrix
0051N-QueensArray, Backtracking
0078SubsetsArray, Backtracking, Bit Manip
0257Binary Tree PathsString, Backtracking, Tree, Depth-First Search, Binary Tree
0401Binary WatchBacktracking, Bit Manip

Prefix Sum

#SolutionTagsDifficultyRemark
1480Running Sum of 1d ArrayArray, Prefix Sum
2574Left and Right Sum DifferencesArray, Prefix Sum

Counting

#SolutionTagsDifficultyRemark
0169Majority ElementArray, Hash Table, Divide and Conquer, Sorting, Counting
0383Ransom NoteHash Table, String, Counting
0387First Unique Character in a StringHash Table, String, Queue, Counting
1512Number of Good PairsArray, Hash Table, Math, Counting

Sliding Window

#SolutionTagsDifficultyRemark
0219Contains Duplicate IIArray, Hash Table, Sliding Window
0438Find All Anagrams in a StringHash Table, String, Sliding Window
2444Count Subarrays With Fixed BoundsArray, Queue, Sliding Window, Monotonic Queue

Linked List

#SolutionTagsDifficultyRemark
0002Add Two NumbersLinked List, Math, Recursion
0021Merge Two Sorted ListsLinked List, Recursion
0024Swap Nodes in PairsLinked List, Recursion
0061Rotate ListLinked List, Two Pointers
0083Remove Duplicates from Sorted ListLL
0109Convert Sorted List to Binary Search TreeLinked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0141Linked List CycleHash Table, Linked List, 2P
0142Linked List Cycle IIHash Table, Linked List, 2P
0160Intersection of Two Linked ListsHash Table, Linked List, 2P
0203Remove Linked List ElementsLinked List, Recursion
0206Reverse Linked ListLinked List, Recursion
0234Palindrome Linked ListLinked List, Two Pointers, Stack, Recursion
0369Plus One Linked ListLinked List, Math🔒
0382Linked List Random NodeLinked List, Math, Reservoir Sampling, Randomized
0445Add Two Numbers IILinked List, Math, Stack
0876Middle of the Linked ListLinked List, Two Pointers
1472Design Browser HistoryArray, Linked List, Stack, Design, Doubly-Linked List, Data Stream

Union Find

#SolutionTagsDifficultyRemark
0200Number of IslandsArray, Depth-First Search, Breadth-First Search, Union Find, Matrix
0695Max Area of IslandArray, Depth-First Search, Breadth-First Search, Union Find, Matrix

Ordered Set

#SolutionTagsDifficultyRemark

Monotonic Stack

#SolutionTagsDifficultyRemark
0042Trapping Rain WaterArray, Two Pointers, Dynamic Programming, Stack, Monotonic Stack
0739Daily TemperaturesArray, Stack, Monotonic Stack

Recursion

#SolutionTagsDifficultyRemark
0002Add Two NumbersLinked List, Math, Recursion
0021Merge Two Sorted ListsLinked List, Recursion
0024Swap Nodes in PairsLinked List, Recursion
0203Remove Linked List ElementsLinked List, Recursion
0206Reverse Linked ListLinked List, Recursion
0231Power of TwoMath, Bit Manipulation, Recursion
0234Palindrome Linked ListLinked List, Two Pointers, Stack, Recursion
0326Power of ThreeMath, Recursion
0342Power of FourMath, Bit Manipulation, Recursion
0344Reverse StringTwo Pointers, String, Recursion
0509Fibonacci NumberMath, Recursion, Dynamic Programming, Memoization

Trie

#SolutionTagsDifficultyRemark
0211Design Add and Search Words Data StructureString, Depth-First Search, Design, Trie

Binary Search Tree

#SolutionTagsDifficultyRemark
0108Convert Sorted Array to Binary Search TreeArray, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0109Convert Sorted List to Binary Search TreeLinked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0530Minimum Absolute Difference in BSTTree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree
0653Two Sum IV - Input is a BST Tree, Depth First Search, Binary Search Tree, Binary Tree
0799Minimum Distance Between BST NodesTree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree

Divide and Conquer

#SolutionTagsDifficultyRemark
0004Median of Two Sorted ArraysArray, Binary Search, Divide & Conquer
0053Maximum SubarrayArray, Divide and Conquer, DP
0106Construct Binary Tree from Inorder and Postorder TraversalArray, Hash Table, Divide and Conquer, Tree, Binary Tree
0108Convert Sorted Array to Binary Search TreeArray, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0109Convert Sorted List to Binary Search TreeLinked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree
0169Majority ElementArray, Hash Table, Divide and Conquer, Sorting, Counting
0190Reverse BitsDivide and Conquer, Bit Manip
0191Number of 1 BitsDivide & Conquer, Bit Manipulation
0912Sort an ArrayArray, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort

Enumeration

#SolutionTagsDifficultyRemark
2427Number of Common FactorsMath, Enumeration, Number Theory

Bitmask

#SolutionTagsDifficultyRemark

Queue

#SolutionTagsDifficultyRemark
0225Implement Stack using QueuesStack, Design, Q
0232Implement Queue using StacksStack, Design, Q
0387First Unique Character in a StringHash Table, String, Queue, Counting
2444Count Subarrays With Fixed BoundsArray, Queue, Sliding Window, Monotonic Queue

Memoization

#SolutionTagsDifficultyRemark
0070Climbing StairsMath, Dynamic Programming, Memoization
0509Fibonacci NumberMath, Recursion, Dynamic Programming, Memoization

Geometry

#SolutionTagsDifficultyRemark
1232Check If It Is a Straight LineArray, Math, Geometry

Topological Sort

#SolutionTagsDifficultyRemark

Segment Tree

#SolutionTagsDifficultyRemark

Game Theory

#SolutionTagsDifficultyRemark
0292Nim GameMath, Brainteaser, Game Theory

Hash Function

#SolutionTagsDifficultyRemark
1461Check If a String Contains All Binary Codes of Size KString, Hash Table, Rolling Hash, Hash Function

Binary Indexed Tree

#SolutionTagsDifficultyRemark

Interactive

#SolutionTagsDifficultyRemark
0278First Bad VersionBinary Search, Interactive
0374Guess Number Higher or LowerBinary Search, Interactive

String Matching

#SolutionTagsDifficultyRemark
0028Find the Index of the First Occurrence in a StringTwo Pointers, String, String Matching

Rolling Hash

#SolutionTagsDifficultyRemark
1461Check If a String Contains All Binary Codes of Size KString, Hash Table, Rolling Hash, Hash Function

Shortest Path

#SolutionTagsDifficultyRemark

Number Theory

#SolutionTagsDifficultyRemark
0258Add DigitsMath, Simulation, Number Theory
2413Smallest Even MultipleMath, Number Theory
2427Number of Common FactorsMath, Enumeration, Number Theory

Data Stream

#SolutionTagsDifficultyRemark
1472Design Browser HistoryArray, Linked List, Stack, Design, Doubly-Linked List, Data Stream

Combinatorics

#SolutionTagsDifficultyRemark

Randomized

#SolutionTagsDifficultyRemark
0382Linked List Random NodeLinked List, Math, Reservoir Sampling, Randomized

Monotonic Queue

#SolutionTagsDifficultyRemark
2444Count Subarrays With Fixed BoundsArray, Queue, Sliding Window, Monotonic Queue

Iterator

#SolutionTagsDifficultyRemark

Merge Sort

#SolutionTagsDifficultyRemark
0912Sort an ArrayArray, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort

Concurrency

#SolutionTagsDifficultyRemark

Doubly Linked List

#SolutionTagsDifficultyRemark

Brainteaser

#SolutionTagsDifficultyRemark
0292Nim GameMath, Brainteaser, Game Theory
2396Strictly Palindromic NumberMath, Two Pointers, Brainteaser

Probability and Statistics

#SolutionTagsDifficultyRemark

Quickselect

#SolutionTagsDifficultyRemark

Bucket Sort

#SolutionTagsDifficultyRemark
0912Sort an ArrayArray, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort

Suffix Array

#SolutionTagsDifficultyRemark

Minimum Spanning Tree

#SolutionTagsDifficultyRemark

Counting Sort

#SolutionTagsDifficultyRemark
0912Sort an ArrayArray, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort

Shell

#SolutionTagsDifficultyRemark
0193Valid Phone NumbersShell
0195Tenth LineShell

Line Sweep

#SolutionTagsDifficultyRemark

Reservoir Sampling

#SolutionTagsDifficultyRemark
0382Linked List Random NodeLinked List, Math, Reservoir Sampling, Randomized

Eulerian Circuit

#SolutionTagsDifficultyRemark

Radix Sort

#SolutionTagsDifficultyRemark
0912Sort an ArrayArray, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort

Strongly Connected Component

#SolutionTagsDifficultyRemark

Rejection Sampling

#SolutionTagsDifficultyRemark

Biconnected Component

#SolutionTagsDifficultyRemark

Released under the MIT License.