English
🏆 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
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0001 | Two Sum | Array, Hash Table | ||
0004 | Median of Two Sorted Arrays | Array, Binary Search, Divide & Conquer | ||
0026 | Remove Duplicates | Array, Two Pointers | ||
0027 | Remove Element | Array, Two Pointers | ||
0035 | Search Insert Position | Array, BS | ||
0037 | Sudoku Solver | Array, Backtracking, Matrix | ||
0041 | First Missing Positive | Array, Hash Table | ||
0042 | Trapping Rain Water | Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack | ||
0048 | Rotate Image | Array, Math, Matrix | ||
0051 | N-Queens | Array, Backtracking | ||
0053 | Maximum Subarray | Array, Divide and Conquer, DP | ||
0055 | Jump Game | Array, Dynamic Programming, Greedy | ||
0066 | Plus One | Array, Math | ||
0074 | Search a 2D Matrix | Array, Binary Search, Matrix | ||
0075 | Sort Colors | Array, Two Pointers, Sorting | ||
0078 | Subsets | Array, Backtracking, Bit Manip | ||
0088 | Merge Sorted Array | Array, Two Pointers, Sorting | ||
0106 | Construct Binary Tree from Inorder and Postorder Traversal | Array, Hash Table, Divide and Conquer, Tree, Binary Tree | ||
0108 | Convert Sorted Array to Binary Search Tree | Array, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0118 | Pascal's Triangle | Array, DP | ||
0119 | Pascal's Triangle II | Array, DP | ||
0121 | Best Time to Buy and Sell Stock | Array, DP | ||
0122 | Best Time to Buy and Sell Stock II | Array, Dynamic Programming, Greedy | ||
0136 | Single Number | Array, Bit Manip | ||
0169 | Majority Element | Array, Hash Table, Divide and Conquer, Sorting, Counting | ||
0200 | Number of Islands | Array, Depth-First Search, Breadth-First Search, Union Find, Matrix | ||
0217 | Contains Duplicate | Array, Hash Table, Sorting | ||
0219 | Contains Duplicate II | Array, Hash Table, Sliding Window | ||
0228 | Summary Ranges | Array | ||
0268 | Missing Number | Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting | ||
0283 | Move Zeroes | Array, Two Pointers | ||
0300 | Longest Increasing Subsequence | Array, Binary Search, DP | ||
0322 | Coin Change | Array, Dynamic Programming, BFS | ||
0349 | Intersection of Two Arrays | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0350 | Intersection of Two Arrays II | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0414 | Third Maximum Number | Array, Sorting | ||
0442 | Find All Duplicates | Array, Hash Table | ||
0448 | Find All Numbers Disappeared in an Array | Array, Hash Table | ||
0463 | Island Perimeter | Array, Depth-First Search, Breadth-First Search, Matrix | ||
0485 | Max Consecutive Ones | Array | ||
0498 | Diagonal Traverse | Array, Matrix, Simulation | ||
0502 | IPO | Array, Greedy, Sorting, Heap (Priority Queue) | ||
0506 | Relative Ranks | Array, Sorting, Heap | ||
0518 | Coin Change 2 | Array, DP | ||
0540 | Single Element in a Sorted Array | Array, BS | ||
0605 | Can Place Flowers | Array, Greedy | ||
0695 | Max Area of Island | Array, Depth-First Search, Breadth-First Search, Union Find, Matrix | ||
0704 | Binary Search | Array, Binary Search | ||
0739 | Daily Temperatures | Array, Stack, Monotonic Stack | ||
0875 | Koko Eating Bananas | Array, BS | ||
0888 | Fair Candy Swap | Array, Hash Table, Binary Search, Sorting | ||
0912 | Sort an Array | Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort | ||
0944 | Delete Columns to Make Sorted | Array, String | ||
0997 | Find the Town Judge | Array, Hash Table, Graph | ||
1011 | Capacity To Ship Packages Within D Days | Array, BS | ||
1029 | Two City Scheduling | Array, Greedy, Sorting | ||
1232 | Check If It Is a Straight Line | Array, Math, Geometry | ||
1345 | Jump Game IV | Array, Hash Table, Breadth-First Search | ||
1431 | Kids With the Greatest Number of Candies | Array | ||
1472 | Design Browser History | Array, Linked List, Stack, Design, Doubly-Linked List, Data Stream | ||
1480 | Running Sum of 1d Array | Array, Prefix Sum | ||
1491 | Average Salary Excluding the Minimum and Maximum | Array, Sorting | ||
1498 | Number of Subsequences That Satisfy the Given Sum Condition | Array, Two Pointers, Binary Search, Sorting | ||
1512 | Number of Good Pairs | Array, Hash Table, Math, Counting | ||
1537 | Get the Maximum Score | Array, Two Pointer, Dynamic Programming, Greedy | ||
1539 | Kth Missing Positive Number | Array, BS | ||
1580 | Shuffle the Array | Array | ||
1672 | Richest Customer Wealth | Array, Matrix | ||
1920 | Build Array from Permutation | Array, Simulation | ||
1929 | Concatenation of Array | Array | ||
2011 | Final Value of Variable After Performing Operations | Array, String, Simulation | ||
2114 | Maximum Number of Words Found in Sentences | Array, String | ||
2176 | Count Equal and Divisible Pairs in an Array | Array | ||
2187 | Minimum Time to Complete Trips | Array, BS | ||
2348 | Number of Zero-Filled Subarrays | Array, Math | ||
2444 | Count Subarrays With Fixed Bounds | Array, Queue, Sliding Window, Monotonic Queue | ||
2551 | Put Marbles in Bags | Array, Greedy, Sorting, Heap (Priority Queue) | ||
2574 | Left and Right Sum Differences | Array, Prefix Sum |
String
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0013 | Roman to Integer | String, Math, Hash Table | ||
0014 | Longest Common Prefix | String | ||
0020 | Valid Parentheses | String, ST | ||
0022 | Generate Parentheses | String, Dynamic Programming, Backtracking | ||
0028 | Find the Index of the First Occurrence in a String | Two Pointers, String, String Matching | ||
0058 | Length of Last Word | String | ||
0067 | Add Binary | Math, String, Bit Manipulation, Simulation | ||
0072 | Edit Distance | String, DP | ||
0125 | Valid Palindrome | Two Pointers, String | ||
0205 | Isomorphic Strings | Hash Table, String | ||
0211 | Design Add and Search Words Data Structure | String, Depth-First Search, Design, Trie | ||
0242 | Valid Anagram | Hash Table, String, Sorting | ||
0257 | Binary Tree Paths | String, Backtracking, Tree, Depth-First Search, Binary Tree | ||
0290 | Word Pattern | Hash Table, String | ||
0344 | Reverse String | Two Pointers, String, Recursion | ||
0345 | Reverse Vowels of a String | Two Pointers, String | ||
0383 | Ransom Note | Hash Table, String, Counting | ||
0387 | First Unique Character in a String | Hash Table, String, Queue, Counting | ||
0389 | Find the Difference | Hash Table, String, Bit Manipulation, Sorting | ||
0392 | Is Subsequence | Two Pointers, String, DP | ||
0412 | Fizz Buzz | Math, String, Simulation | ||
0434 | Number of Segments in a String | String | ||
0438 | Find All Anagrams in a String | Hash Table, String, Sliding Window | ||
0443 | String Compression | Two Pointers, String | ||
0482 | License Key Formatting | String | ||
0516 | Longest Palindromic Subsequence | String, DP | ||
0541 | Reverse String II | Two Pointers, String | ||
0771 | Jewels and Stones | String, Hashtable | ||
0944 | Delete Columns to Make Sorted | Array, String | ||
1047 | Remove All Adjacent Duplicates In String | String, Stack | ||
1092 | Shortest Common Supersequence | String, DP | ||
1108 | Defanging an IP Address | String | ||
1143 | Longest Common Subsequence | String, DP | ||
1461 | Check If a String Contains All Binary Codes of Size K | String, Hash Table, Bit Manipulation | ||
1689 | Partitioning Into Minimum Number Of Deci-Binary Numbers | String, Greedy | ||
1957 | Delete Characters to Make Fancy String | String | ||
2011 | Final Value of Variable After Performing Operations | Array, String, Simulation | ||
2114 | Maximum Number of Words Found in Sentences | Array, String |
Hash Table
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0001 | Two Sum | Array, Hash Table | ||
0013 | Roman to Integer | String, Math, Hash Table | ||
0041 | First Missing Positive | Array, Hash Table | ||
0106 | Construct Binary Tree from Inorder and Postorder Traversal | Array, Hash Table, Divide and Conquer, Tree, Binary Tree | ||
0141 | Linked List Cycle | Hash Table, Linked List, 2P | ||
0142 | Linked List Cycle II | Hash Table, Linked List, 2P | ||
0160 | Intersection of Two Linked Lists | Hash Table, Linked List, 2P | ||
0169 | Majority Element | Array, Hash Table, Divide and Conquer, Sorting, Counting | ||
0202 | Happy Number | Hash Table, Math, 2P | ||
0205 | Isomorphic Strings | Hash Table, String | ||
0217 | Contains Duplicate | Array, Hash Table, Sorting | ||
0219 | Contains Duplicate II | Array, Hash Table, Sliding Window | ||
0242 | Valid Anagram | Hash Table, String, Sorting | ||
0268 | Missing Number | Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting | ||
0290 | Word Pattern | Hash Table, String | ||
0349 | Intersection of Two Arrays | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0350 | Intersection of Two Arrays II | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0383 | Ransom Note | Hash Table, String, Counting | ||
0387 | First Unique Character in a String | Hash Table, String, Queue, Counting | ||
0389 | Find the Difference | Hash Table, String, Bit Manipulation, Sorting | ||
0438 | Find All Anagrams in a String | Hash Table, String, Sliding Window | ||
0442 | Find All Duplicates | Array, Hash Table | ||
0448 | Find All Numbers Disappeared in an Array | Array, Hash Table | ||
0652 | Find Duplicate Subtrees | Hash Table, Tree, Depth-First Search, Binary Tree | ||
0653 | Two Sum IV - Input is a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0888 | Fair Candy Swap | Array, Hash Table, Binary Search, Sorting | ||
0771 | Jewels and Stones | String, Hashtable | ||
0997 | Find the Town Judge | Array, Hash Table, Graph | ||
1345 | Jump Game IV | Array, Hash Table, Breadth-First Search | ||
1512 | Number of Good Pairs | Array, Hash Table, Math, Counting |
Dynamic Programming
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0022 | Generate Parentheses | String, Dynamic Programming, Backtracking | ||
0042 | Trapping Rain Water | Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack | ||
0053 | Maximum Subarray | Array, Divide and Conquer, DP | ||
0055 | Jump Game | Array, Dynamic Programming, Greedy | ||
0070 | Climbing Stairs | Math, Dynamic Programming, Memoization | ||
0072 | Edit Distance | String, DP | ||
0118 | Pascal's Triangle | Array, DP | ||
0119 | Pascal's Triangle II | Array, DP | ||
0121 | Best Time to Buy and Sell Stock | Array, DP | ||
0122 | Best Time to Buy and Sell Stock II | Array, Dynamic Programming, Greedy | ||
0279 | Perfect Squares | Math, Dynamic Programming, Breadth-First Search | ||
0300 | Longest Increasing Subsequence | Array, Binary Search, DP | ||
0322 | Coin Change | Array, Dynamic Programming, BFS | ||
0337 | House Robber III | Dynamic Programming, Tree, Depth First Search, Binary Tree | ||
0338 | Counting Bits | Dynamic Programming, Bit Manip | ||
0392 | Is Subsequence | Two Pointers, String, DP | ||
0509 | Fibonacci Number | Math, Recursion, Dynamic Programming, Memoization | ||
0516 | Longest Palindromic Subsequence | String, DP | ||
0518 | Coin Change 2 | Array, DP | ||
1092 | Shortest Common Supersequence | String, DP | ||
1143 | Longest Common Subsequence | String, DP | ||
1537 | Get the Maximum Score | Array, Two Pointer, Dynamic Programming, Greedy |
Math
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0002 | Add Two Numbers | Linked List, Math, Recursion | ||
0007 | Reverse Integer | Math | ||
0009 | Palindrome Number | Math | ||
0013 | Roman to Integer | String, Math, Hash Table | ||
0048 | Rotate Image | Array, Math, Matrix | ||
0066 | Plus One | Array, Math | ||
0067 | Add Binary | Math, String, Bit Manipulation, Simulation | ||
0069 | Sqrt(x) | Math, BS | ||
0070 | Climbing Stairs | Math, Dynamic Programming, Memorization | ||
0172 | Factorial Trailiing Zeroes | Math | ||
0202 | Happy Number | Hash Table, Math, 2P | ||
0231 | Power of Two | Math, Bit Manipulation, Recursion | ||
0258 | Add Digits | Math, Simulation, Number Theory | ||
0263 | Ugly Number | Math | ||
0268 | Missing Number | Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting | ||
0279 | Perfect Squares | Math, Dynamic Programming, Breadth-First Search | ||
0292 | Nim Game | Math, Brainteaser, Game Theory | ||
0326 | Power of Three | Math, Recursion | ||
0342 | Power of Four | Math, Bit Manipulation, Recursion | ||
0367 | Valid Perfect Square | Math, Binary Search | ||
0382 | Linked List Random Node | Linked List, Math, Reservoir Sampling, Randomized | ||
0412 | Fizz Buzz | Math, String, Simulation | ||
0441 | Arranging Coins | Math, BS | ||
0445 | Add Two Numbers II | Linked List, Math, Stack | ||
0492 | Construct the Rectangle | Math | ||
0504 | Base 7 | Math | ||
0507 | Perfect Number | Math | ||
0509 | Fibonacci Number | Math, Recursion, Dynamic Programming, Memoization | ||
1232 | Check If It Is a Straight Line | Array, Math, Geometry | ||
1512 | Number of Good Pairs | Array, Hash Table, Math, Counting | ||
1630 | Count Odd Numbers in an Interval Range | Math | ||
2160 | Minimum Sum of Four Digit Number After Splitting Digits | Math, Greedy, Sorting | ||
2235 | Add Two Integers | Math | ||
2348 | Number of Zero-Filled Subarrays | Array, Math | ||
2396 | Strictly Palindromic Number | Math, Two Pointers, Brainteaser | ||
2413 | Smallest Even Multiple | Math, Number Theory | ||
2427 | Number of Common Factors | Math, Enumeration, Number Theory | ||
2469 | Convert the Temperature | Math |
Sorting
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0075 | Sort Colors | Array, Two Pointers, Sorting | ||
0088 | Merge Sorted Array | Array, Two Pointers, Sorting | ||
0169 | Majority Element | Array, Hash Table, Divide and Conquer, Sorting, Counting | ||
0217 | Contains Duplicate | Array, Hash Table, Sorting | ||
0242 | Valid Anagram | Hash Table, String, Sorting | ||
0268 | Missing Number | Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting | ||
0349 | Intersection of Two Arrays | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0350 | Intersection of Two Arrays II | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0389 | Find the Difference | Hash Table, String, Bit Manipulation, Sorting | ||
0414 | Third Maximum Number | Array, Sorting | ||
0502 | IPO | Array, Greedy, Sorting, Heap (Priority Queue) | ||
0506 | Relative Ranks | Array, Sorting, Heap | ||
0888 | Fair Candy Swap | Array, Hash Table, Binary Search, Sorting | ||
0912 | Sort an Array | Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort | ||
1029 | Two City Scheduling | Array, Greedy, Sorting | ||
1498 | Number of Subsequences That Satisfy the Given Sum Condition | Array, Two Pointers, Binary Search, Sorting | ||
1491 | Average Salary Excluding the Minimum and Maximum | Array, Sorting | ||
2160 | Minimum Sum of Four Digit Number After Splitting Digits | Math, Greedy, Sorting | ||
2551 | Put Marbles in Bags | Array, Greedy, Sorting, Heap (Priority Queue) |
Depth First Search
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0100 | Same Tree | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0104 | Maximum Depth of Binary Tree | Tree, Breadth First Search, Depth First Search, Binary Tree | ||
0110 | Balanced Binary Tree | Tree, Depth First Search, Binary Tree | ||
0111 | Minimum Depth of Binary Tree | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0144 | Binary Tree Preorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0145 | Binary Tree Postorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0199 | Binary Tree Right Side View | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0222 | Count Complete Tree Nodes | Binary Search, Tree, Depth First Search, Binary Tree | ||
0230 | Kth Smallest Element in a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0337 | House Robber III | Dynamic Programming, Tree, Depth First Search, Binary Tree | ||
0543 | Diameter of Binary Tree | Tree, Depth First Search, Binary Tree | ||
0653 | Two Sum IV - Input is a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree |
Greedy
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0055 | Jump Game | Array, Dynamic Programming, Greedy | ||
0094 | Binary Tree Inorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0098 | Validate Binary Search Tree | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0122 | Best Time to Buy and Sell Stock II | Array, Dynamic Programming, Greedy | ||
0502 | IPO | Array, Greedy, Sorting, Heap (Priority Queue) | ||
0605 | Can Place Flowers | Array, Greedy | ||
1029 | Two City Scheduling | Array, Greedy, Sorting | ||
1537 | Get the Maximum Score | Array, Two Pointer, Dynamic Programming, Greedy | ||
1689 | Partitioning Into Minimum Number Of Deci-Binary Numbers | String, Greedy | ||
2160 | Minimum Sum of Four Digit Number After Splitting Digits | Math, Greedy, Sorting | ||
2551 | Put Marbles in Bags | Array, Greedy, Sorting, Heap (Priority Queue) |
Database
# | Solution | Tags | Difficulty | Remark |
---|
Breadth First Search
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0100 | Same Tree | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0103 | Binary Tree Zigzag Level Order Traversal | Tree, Breadth First Search, Binary Tree | ||
0104 | Maximum Depth of Binary Tree | Tree, Breadth First Search, Depth First Search, Binary Tree | ||
0111 | Minimum Depth of Binary Tree | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0199 | Binary Tree Right Side View | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0230 | Kth Smallest Element in a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0322 | Coin Change | Array, Dynamic Programming, BFS | ||
0653 | Two Sum IV - Input is a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree |
Tree
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0094 | Binary Tree Inorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0098 | Validate Binary Search Tree | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0100 | Same Tree | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0101 | Symmetric Tree | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0103 | Binary Tree Zigzag Level Order Traversal | Tree, Breadth First Search, Binary Tree | ||
0104 | Maximum Depth of Binary Tree | Tree, Breadth First Search, Depth First Search, Binary Tree | ||
0106 | Construct Binary Tree from Inorder and Postorder Traversal | Array, Hash Table, Divide and Conquer, Tree, Binary Tree | ||
0108 | Convert Sorted Array to Binary Search Tree | Array, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0109 | Convert Sorted List to Binary Search Tree | Linked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0110 | Balanced Binary Tree | Tree, Depth First Search, Binary Tree | ||
0111 | Minimum Depth of Binary Tree | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0112 | Path Sum | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0129 | Sum Root to Leaf Numbers | Tree, Depth-First Search, Binary Tree | ||
0144 | Binary Tree Preorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0145 | Binary Tree Postorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0199 | Binary Tree Right Side View | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0222 | Count Complete Tree Nodes | Binary Search, Tree, Depth First Search, Binary Tree | ||
0226 | Invert Binary Tree | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0230 | Kth Smallest Element in a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0236 | Lowest Common Ancestor of a Binary Tree | Tree, Depth-First Search, Binary Tree | ||
0257 | Binary Tree Paths | String, Backtracking, Tree, Depth-First Search, Binary Tree | ||
0337 | House Robber III | Dynamic Programming, Tree, Depth First Search, Binary Tree | ||
0404 | Sum of Left Leaves | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0530 | Minimum Absolute Difference in BST | Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree | ||
0543 | Diameter of Binary Tree | Tree, Depth First Search, Binary Tree | ||
0652 | Find Duplicate Subtrees | Hash Table, Tree, Depth-First Search, Binary Tree | ||
0653 | Two Sum IV - Input is a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0799 | Minimum Distance Between BST Nodes | Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree | ||
0958 | Check Completeness of a Binary Tree | Tree, Breadth-First Search, Binary Tree | ||
2236 | Root Equal to Sum of Children | Tree, Binary Tree |
Binary Search
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0004 | Median of Two Sorted Arrays | Array, Binary Search, Divide & Conquer | ||
0035 | Search Insert Position | Array, BS | ||
0069 | Sqrt(x) | Math, BS | ||
0074 | Search a 2D Matrix | Array, Binary Search, Matrix | ||
0222 | Count Complete Tree Nodes | Binary Search, Tree, Depth First Search, Binary Tree | ||
0268 | Missing Number | Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting | ||
0278 | First Bad Version | Binary Search, Interactive | ||
0300 | Longest Increasing Subsequence | Array, Binary Search, DP | ||
0349 | Intersection of Two Arrays | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0350 | Intersection of Two Arrays II | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0367 | Valid Perfect Square | Math, Binary Search | ||
0374 | Guess Number Higher or Lower | Binary Search, Interactive | ||
0441 | Arranging Coins | Math, BS | ||
0540 | Single Element in a Sorted Array | Array, BS | ||
0704 | Binary Search | Array, Binary Search | ||
0875 | Koko Eating Bananas | Array, BS | ||
1011 | Capacity To Ship Packages Within D Days | Array, BS | ||
1498 | Number of Subsequences That Satisfy the Given Sum Condition | Array, Two Pointers, Binary Search, Sorting | ||
0888 | Fair Candy Swap | Array, Hash Table, Binary Search, Sorting | ||
1539 | Kth Missing Positive Number | Array, BS | ||
2187 | Minimum Time to Complete Trips | Array, BS |
Matrix
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0037 | Sudoku Solver | Array, Backtracking, Matrix | ||
0048 | Rotate Image | Array, Math, Matrix | ||
0074 | Search a 2D Matrix | Array, Binary Search, Matrix | ||
0200 | Number of Islands | Array, Depth-First Search, Breadth-First Search, Union Find, Matrix | ||
0463 | Island Perimeter | Array, Depth-First Search, Breadth-First Search, Matrix | ||
0498 | Diagonal Traverse | Array, Matrix, Simulation | ||
0695 | Max Area of Island | Array, Depth-First Search, Breadth-First Search, Union Find, Matrix | ||
1672 | Richest Customer Wealth | Array, Matrix |
Binary Tree
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0094 | Binary Tree Inorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0098 | Validate Binary Search Tree | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0100 | Same Tree | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0101 | Symmetric Tree | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0103 | Binary Tree Zigzag Level Order Traversal | Tree, Breadth First Search, Binary Tree | ||
0104 | Maximum Depth of Binary Tree | Tree, Breadth First Search, Depth First Search, Binary Tree | ||
0106 | Construct Binary Tree from Inorder and Postorder Traversal | Array, Hash Table, Divide and Conquer, Tree, Binary Tree | ||
0108 | Convert Sorted Array to Binary Search Tree | Array, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0109 | Convert Sorted List to Binary Search Tree | Linked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0110 | Balanced Binary Tree | Tree, Depth First Search, Binary Tree | ||
0111 | Minimum Depth of Binary Tree | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0112 | Path Sum | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0129 | Sum Root to Leaf Numbers | Tree, Depth-First Search, Binary Tree | ||
0144 | Binary Tree Preorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0145 | Binary Tree Postorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0199 | Binary Tree Right Side View | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0222 | Count Complete Tree Nodes | Binary Search, Tree, Depth First Search, Binary Tree | ||
0226 | Invert Binary Tree | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0230 | Kth Smallest Element in a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0236 | Lowest Common Ancestor of a Binary Tree | Tree, Depth-First Search, Binary Tree | ||
0257 | Binary Tree Paths | String, Backtracking, Tree, Depth-First Search, Binary Tree | ||
0337 | House Robber III | Dynamic Programming, Tree, Depth First Search, Binary Tree | ||
0404 | Sum of Left Leaves | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0530 | Minimum Absolute Difference in BST | Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree | ||
0543 | Diameter of Binary Tree | Tree, Depth First Search, Binary Tree | ||
0652 | Find Duplicate Subtrees | Hash Table, Tree, Depth-First Search, Binary Tree | ||
0653 | Two Sum IV - Input is a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0799 | Minimum Distance Between BST Nodes | Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree | ||
0958 | Check Completeness of a Binary Tree | Tree, Breadth-First Search, Binary Tree | ||
2236 | Root Equal to Sum of Children | Tree, Binary Tree |
Two Pointers
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0004 | Median of Two Sorted Arrays | Array, Binary Search, Divide & Conquer | ||
0027 | Remove Element | Array, Two Pointers | ||
0028 | Find the Index of the First Occurrence in a String | Two Pointers, String, String Matching | ||
0042 | Trapping Rain Water | Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack | ||
0061 | Rotate List | Linked List, Two Pointers | ||
0075 | Sort Colors | Array, Two Pointers, Sorting | ||
0088 | Merge Sorted Array | Array, Two Pointers, Sorting | ||
0125 | Valid Palindrome | Two Pointers, String | ||
0141 | Linked List Cycle | Hash Table, Linked List, 2P | ||
0142 | Linked List Cycle II | Hash Table, Linked List, 2P | ||
0160 | Intersection of Two Linked Lists | Hash Table, Linked List, 2P | ||
0202 | Happy Number | Hash Table, Math, 2P | ||
0234 | Palindrome Linked List | Linked List, Two Pointers, Stack, Recursion | ||
0283 | Move Zeroes | Array, Two Pointers | ||
0344 | Reverse String | Two Pointers, String, Recursion | ||
0345 | Reverse Vowels of a String | Two Pointers, String | ||
0349 | Intersection of Two Arrays | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0350 | Intersection of Two Arrays II | Array, Hash Table, Two Pointers, Binary Search, Sorting | ||
0392 | Is Subsequence | Two Pointers, String, DP | ||
0443 | String Compression | Two Pointers, String | ||
0541 | Reverse String II | Two Pointers, String | ||
0653 | Two Sum IV - Input is a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0876 | Middle of the Linked List | Linked List, Two Pointers | ||
1498 | Number of Subsequences That Satisfy the Given Sum Condition | Array, Two Pointers, Binary Search, Sorting | ||
1537 | Get the Maximum Score | Array, Two Pointer, Dynamic Programming, Greedy | ||
2396 | Strictly Palindromic Number | Math, Two Pointers, Brainteaser |
Bit Manipulation
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0067 | Add Binary | Math, String, Bit Manipulation, Simulation | ||
0078 | Subsets | Array, Backtracking, Bit Manip | ||
0136 | Single Number | Array, Bit Manip | ||
0190 | Reverse Bits | Divide and Conquer, Bit Manip | ||
0191 | Number of 1 Bits | Divide & Conquer, Bit Manipulation | ||
0231 | Power of Two | Math, Bit Manipulation, Recursion | ||
0268 | Missing Number | Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting | ||
0338 | Counting Bits | Dynamic Programming, Bit Manip | ||
0342 | Power of Four | Math, Bit Manipulation, Recursion | ||
0389 | Find the Difference | Hash Table, String, Bit Manipulation, Sorting | ||
0401 | Binary Watch | Backtracking, Bit Manip | ||
0461 | Hamming Distance | Bit Manip | ||
0476 | Number Complement | Bit Manip | ||
1461 | Check If a String Contains All Binary Codes of Size K | String, Hash Table, Bit Manipulation |
Stack
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0020 | Valid Parentheses | String, ST | ||
0042 | Trapping Rain Water | Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack | ||
0094 | Binary Tree Inorder Traversal | Tree, Stack, Depth First Search, Binary Tree | ||
0144 | Binary Tree Preorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0145 | Binary Tree Postorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0225 | Implement Stack using Queues | Stack, Design, Q | ||
0232 | Implement Queue using Stacks | Stack, Design, Q | ||
0234 | Palindrome Linked List | Linked List, Two Pointers, Stack, Recursion | ||
0445 | Add Two Numbers II | Linked List, Math, Stack | ||
0739 | Daily Temperatures | Array, Stack, Monotonic Stack | ||
1047 | Remove All Adjacent Duplicates In String | String, Stack | ||
1472 | Design Browser History | Array, Linked List, Stack, Design, Doubly-Linked List, Data Stream |
Design
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0211 | Design Add and Search Words Data Structure | String, Depth-First Search, Design, Trie | ||
0225 | Implement Stack using Queues | Stack, Design, Q | ||
0232 | Implement Queue using Stacks | Stack, Design, Q | ||
1472 | Design Browser History | Array, Linked List, Stack, Design, Doubly-Linked List, Data Stream |
Heap (Priority Queue)
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0506 | Relative Ranks | Array, Sorting, Heap |
Graph
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0997 | Find the Town Judge | Array, Hash Table, Graph |
Simulation
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0067 | Add Binary | Math, String, Bit Manipulation, Simulation | ||
0258 | Add Digits | Math, Simulation, Number Theory | ||
0412 | Fizz Buzz | Math, String, Simulation | ||
0498 | Diagonal Traverse | Array, Matrix, Simulation | ||
1920 | Build Array from Permutation | Array, Simulation | ||
2011 | Final Value of Variable After Performing Operations | Array, String, Simulation |
Backtracking
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0022 | Generate Parentheses | String, Dynamic Programming, Backtracking | ||
0037 | Sudoku Solver | Array, Backtracking, Matrix | ||
0051 | N-Queens | Array, Backtracking | ||
0078 | Subsets | Array, Backtracking, Bit Manip | ||
0257 | Binary Tree Paths | String, Backtracking, Tree, Depth-First Search, Binary Tree | ||
0401 | Binary Watch | Backtracking, Bit Manip |
Prefix Sum
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
1480 | Running Sum of 1d Array | Array, Prefix Sum | ||
2574 | Left and Right Sum Differences | Array, Prefix Sum |
Counting
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0169 | Majority Element | Array, Hash Table, Divide and Conquer, Sorting, Counting | ||
0383 | Ransom Note | Hash Table, String, Counting | ||
0387 | First Unique Character in a String | Hash Table, String, Queue, Counting | ||
1512 | Number of Good Pairs | Array, Hash Table, Math, Counting |
Sliding Window
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0219 | Contains Duplicate II | Array, Hash Table, Sliding Window | ||
0438 | Find All Anagrams in a String | Hash Table, String, Sliding Window | ||
2444 | Count Subarrays With Fixed Bounds | Array, Queue, Sliding Window, Monotonic Queue |
Linked List
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0002 | Add Two Numbers | Linked List, Math, Recursion | ||
0021 | Merge Two Sorted Lists | Linked List, Recursion | ||
0024 | Swap Nodes in Pairs | Linked List, Recursion | ||
0061 | Rotate List | Linked List, Two Pointers | ||
0083 | Remove Duplicates from Sorted List | LL | ||
0109 | Convert Sorted List to Binary Search Tree | Linked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0141 | Linked List Cycle | Hash Table, Linked List, 2P | ||
0142 | Linked List Cycle II | Hash Table, Linked List, 2P | ||
0160 | Intersection of Two Linked Lists | Hash Table, Linked List, 2P | ||
0203 | Remove Linked List Elements | Linked List, Recursion | ||
0206 | Reverse Linked List | Linked List, Recursion | ||
0234 | Palindrome Linked List | Linked List, Two Pointers, Stack, Recursion | ||
0369 | Plus One Linked List | Linked List, Math | 🔒 | |
0382 | Linked List Random Node | Linked List, Math, Reservoir Sampling, Randomized | ||
0445 | Add Two Numbers II | Linked List, Math, Stack | ||
0876 | Middle of the Linked List | Linked List, Two Pointers | ||
1472 | Design Browser History | Array, Linked List, Stack, Design, Doubly-Linked List, Data Stream |
Union Find
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0200 | Number of Islands | Array, Depth-First Search, Breadth-First Search, Union Find, Matrix | ||
0695 | Max Area of Island | Array, Depth-First Search, Breadth-First Search, Union Find, Matrix |
Ordered Set
# | Solution | Tags | Difficulty | Remark |
---|
Monotonic Stack
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0042 | Trapping Rain Water | Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack | ||
0739 | Daily Temperatures | Array, Stack, Monotonic Stack |
Recursion
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0002 | Add Two Numbers | Linked List, Math, Recursion | ||
0021 | Merge Two Sorted Lists | Linked List, Recursion | ||
0024 | Swap Nodes in Pairs | Linked List, Recursion | ||
0203 | Remove Linked List Elements | Linked List, Recursion | ||
0206 | Reverse Linked List | Linked List, Recursion | ||
0231 | Power of Two | Math, Bit Manipulation, Recursion | ||
0234 | Palindrome Linked List | Linked List, Two Pointers, Stack, Recursion | ||
0326 | Power of Three | Math, Recursion | ||
0342 | Power of Four | Math, Bit Manipulation, Recursion | ||
0344 | Reverse String | Two Pointers, String, Recursion | ||
0509 | Fibonacci Number | Math, Recursion, Dynamic Programming, Memoization |
Trie
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0211 | Design Add and Search Words Data Structure | String, Depth-First Search, Design, Trie |
Binary Search Tree
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0108 | Convert Sorted Array to Binary Search Tree | Array, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0109 | Convert Sorted List to Binary Search Tree | Linked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0530 | Minimum Absolute Difference in BST | Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree | ||
0653 | Two Sum IV - Input is a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0799 | Minimum Distance Between BST Nodes | Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree |
Divide and Conquer
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0004 | Median of Two Sorted Arrays | Array, Binary Search, Divide & Conquer | ||
0053 | Maximum Subarray | Array, Divide and Conquer, DP | ||
0106 | Construct Binary Tree from Inorder and Postorder Traversal | Array, Hash Table, Divide and Conquer, Tree, Binary Tree | ||
0108 | Convert Sorted Array to Binary Search Tree | Array, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0109 | Convert Sorted List to Binary Search Tree | Linked List, Divide and Conquer, Tree, Binary Search Tree, Binary Tree | ||
0169 | Majority Element | Array, Hash Table, Divide and Conquer, Sorting, Counting | ||
0190 | Reverse Bits | Divide and Conquer, Bit Manip | ||
0191 | Number of 1 Bits | Divide & Conquer, Bit Manipulation | ||
0912 | Sort an Array | Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort |
Enumeration
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
2427 | Number of Common Factors | Math, Enumeration, Number Theory |
Bitmask
# | Solution | Tags | Difficulty | Remark |
---|
Queue
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0225 | Implement Stack using Queues | Stack, Design, Q | ||
0232 | Implement Queue using Stacks | Stack, Design, Q | ||
0387 | First Unique Character in a String | Hash Table, String, Queue, Counting | ||
2444 | Count Subarrays With Fixed Bounds | Array, Queue, Sliding Window, Monotonic Queue |
Memoization
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0070 | Climbing Stairs | Math, Dynamic Programming, Memoization | ||
0509 | Fibonacci Number | Math, Recursion, Dynamic Programming, Memoization |
Geometry
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
1232 | Check If It Is a Straight Line | Array, Math, Geometry |
Topological Sort
# | Solution | Tags | Difficulty | Remark |
---|
Segment Tree
# | Solution | Tags | Difficulty | Remark |
---|
Game Theory
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0292 | Nim Game | Math, Brainteaser, Game Theory |
Hash Function
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
1461 | Check If a String Contains All Binary Codes of Size K | String, Hash Table, Rolling Hash, Hash Function |
Binary Indexed Tree
# | Solution | Tags | Difficulty | Remark |
---|
Interactive
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0278 | First Bad Version | Binary Search, Interactive | ||
0374 | Guess Number Higher or Lower | Binary Search, Interactive |
String Matching
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0028 | Find the Index of the First Occurrence in a String | Two Pointers, String, String Matching |
Rolling Hash
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
1461 | Check If a String Contains All Binary Codes of Size K | String, Hash Table, Rolling Hash, Hash Function |
Shortest Path
# | Solution | Tags | Difficulty | Remark |
---|
Number Theory
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0258 | Add Digits | Math, Simulation, Number Theory | ||
2413 | Smallest Even Multiple | Math, Number Theory | ||
2427 | Number of Common Factors | Math, Enumeration, Number Theory |
Data Stream
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
1472 | Design Browser History | Array, Linked List, Stack, Design, Doubly-Linked List, Data Stream |
Combinatorics
# | Solution | Tags | Difficulty | Remark |
---|
Randomized
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0382 | Linked List Random Node | Linked List, Math, Reservoir Sampling, Randomized |
Monotonic Queue
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
2444 | Count Subarrays With Fixed Bounds | Array, Queue, Sliding Window, Monotonic Queue |
Iterator
# | Solution | Tags | Difficulty | Remark |
---|
Merge Sort
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0912 | Sort an Array | Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort |
Concurrency
# | Solution | Tags | Difficulty | Remark |
---|
Doubly Linked List
# | Solution | Tags | Difficulty | Remark |
---|
Brainteaser
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0292 | Nim Game | Math, Brainteaser, Game Theory | ||
2396 | Strictly Palindromic Number | Math, Two Pointers, Brainteaser |
Probability and Statistics
# | Solution | Tags | Difficulty | Remark |
---|
Quickselect
# | Solution | Tags | Difficulty | Remark |
---|
Bucket Sort
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0912 | Sort an Array | Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort |
Suffix Array
# | Solution | Tags | Difficulty | Remark |
---|
Minimum Spanning Tree
# | Solution | Tags | Difficulty | Remark |
---|
Counting Sort
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0912 | Sort an Array | Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort |
Shell
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0193 | Valid Phone Numbers | Shell | ||
0195 | Tenth Line | Shell |
Line Sweep
# | Solution | Tags | Difficulty | Remark |
---|
Reservoir Sampling
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0382 | Linked List Random Node | Linked List, Math, Reservoir Sampling, Randomized |
Eulerian Circuit
# | Solution | Tags | Difficulty | Remark |
---|
Radix Sort
# | Solution | Tags | Difficulty | Remark |
---|---|---|---|---|
0912 | Sort an Array | Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort |
Strongly Connected Component
# | Solution | Tags | Difficulty | Remark |
---|
Rejection Sampling
# | Solution | Tags | Difficulty | Remark |
---|
Biconnected Component
# | Solution | Tags | Difficulty | Remark |
---|