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
# | Solution | Tag | Difficulty | Remark |
---|---|---|---|---|
0001 | Two Sum | Array, Hash Table | ||
0002 | Add Two Numbers | Linked List, Math, Recursion | ||
0004 | Median of Two Sorted Arrays | Array, Binary Search, Divide & Conquer | ||
0007 | Reverse Integer | Math | ||
0009 | Palindrome Number | Math | ||
0013 | Roman to Integer | String, Math, Hash Table | ||
0014 | Longest Common Prefix | String | ||
0020 | Valid Parentheses | String, ST | ||
0021 | Merge Two Sorted Lists | Linked List, Recursion | ||
0022 | Generate Parentheses | String, Dynamic Programming, Backtracking | ||
0024 | Swap Nodes in Pairs | Linked List, Recursion | ||
0026 | Remove Duplicates | Array, Two Pointers | ||
0027 | Remove Element | Array, Two Pointers | ||
0028 | Find the Index of the First Occurrence in a String | Two Pointers, String, String Matching | ||
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 | ||
0058 | Length of Last Word | String | ||
0061 | Rotate List | Linked List, Two Pointers | ||
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 | ||
0072 | Edit Distance | String, DP | ||
0074 | Search a 2D Matrix | Array, Binary Search, Matrix | ||
0075 | Sort Colors | Array, Two Pointers, Sorting | ||
0078 | Subsets | Array, Backtracking, Bit Manip | ||
0083 | Remove Duplicates from Sorted List | LL | ||
0088 | Merge Sorted Array | Array, Two Pointers, Sorting | ||
0094 | Binary Tree Inorder Traversal | Tree, Stack, Depth First Search, Binary Tree | ||
0098 | Validate BST | 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 | ||
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 | ||
0125 | Valid Palindrome | Two Pointers, String | ||
0129 | Sum Root to Leaf Numbers | Tree, Depth-First Search, Binary Tree | ||
0136 | Single Number | Array, Bit Manip | ||
0141 | Linked List Cycle | Hash Table, Linked List, 2P | ||
0142 | Linked List Cycle II | Hash Table, Linked List, 2P | ||
0144 | Binary Tree Preorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0145 | Binary Tree Postorder Traversal | Stack, Tree, Depth First Search, Binary Tree | ||
0160 | Intersection of Two Linked Lists | Hash Table, Linked List, 2P | ||
0169 | Majority Element | Array, Hash Table, Divide and Conquer, Sorting, Counting | ||
0172 | Factorial Trailing Zeroes | Math | ||
0190 | Reverse Bits | Divide and Conquer, Bit Manip | ||
0191 | Number of 1 Bits | Divide & Conquer, Bit Manipulation | ||
0193 | Valid Phone Numbers | Shell | ||
0195 | Tenth Line | Shell | ||
0199 | Binary Tree Right Side View | Tree, Depth First Search, Breadth First Search, Binary Tree | ||
0200 | Number of Islands | Array, Depth-First Search, Breadth-First Search, Union Find, Matrix | ||
0202 | Happy Number | Hash Table, Math, 2P | ||
0203 | Remove Linked List Elements | Linked List, Recursion | ||
0205 | Isomorphic Strings | Hash Table, String | ||
0206 | Reverse Linked List | Linked List, Recursion | ||
0211 | Design Add and Search Words Data Structure | String, Depth-First Search, Design, Trie | ||
0217 | Contains Duplicate | Array, Hash Table, Sorting | ||
0219 | Contains Duplicate II | Array, Hash Table, Sliding Window | ||
0222 | Count Complete Tree Nodes | Binary Search, Tree, Depth First Search, Binary Tree | ||
0225 | Implement Stack using Queues | Stack, Design, Q | ||
0226 | Invert Binary Tree | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0228 | Summary Ranges | Array | ||
0230 | Kth Smallest Element in a BST | Tree, Depth First Search, Binary Search Tree, Binary Tree | ||
0231 | Power of Two | Math, Bit Manipulation, Recursion | ||
0232 | Implement Queue using Stacks | Stack, Design, Q | ||
0234 | Palindrome Linked List | Linked List, Two Pointers, Stack, Recursion | ||
0236 | Lowest Common Ancestor of a Binary Tree | Tree, Depth-First Search, Binary Tree | ||
0242 | Valid Anagram | Hash Table, String, Sorting | ||
0257 | Binary Tree Paths | String, Backtracking, Tree, Depth-First Search, Binary Tree | ||
0258 | Add Digits | Math, Simulation, Number Theory | ||
0263 | Ugly Number | Math | ||
0268 | Missing Number | Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting | ||
0278 | First Bad Version | Binary Search, Interactive | ||
0279 | Perfect Squares | Math, Dynamic Programming, Breadth-First Search | ||
0283 | Move Zeroes | Array, Two Pointers | ||
0290 | Word Pattern | Hash Table, String | ||
0292 | Nim Game | Math, Brainteaser, Game Theory | ||
0300 | Longest Increasing Subsequence | Array, Binary Search, DP | ||
0322 | Coin Change | Array, Dynamic Programming, BFS | ||
0326 | Power of Three | Math, Recursion | ||
0337 | House Robber III | Dynamic Programming, Tree, Depth First Search, Binary Tree | ||
0338 | Counting Bits | Dynamic Programming, Bit Manip | ||
0342 | Power of Four | Math, Bit Manipulation, Recursion | ||
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 | ||
0367 | Valid Perfect Square | Math, Binary Search | ||
0369 | Plus One Linked List | Linked List, Math | 🔒 | |
0374 | Guess Number Higher or Lower | Binary Search, Interactive | ||
0382 | Linked List Random Node | Linked List, Math, Reservoir Sampling, Randomized | ||
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 | ||
0401 | Binary Watch | Backtracking, Bit Manip | ||
0404 | Sum of Left Leaves | Tree, Depth-First Search, Breadth-First Search, Binary Tree | ||
0412 | Fizz Buzz | Math, String, Simulation | ||
0414 | Third Maximum Number | Array, Sorting | ||
0434 | Number of Segments in a String | String | ||
0438 | Find All Anagrams in a String | Hash Table, String, Sliding Window | ||
0441 | Arranging Coins | Math, BS | ||
0442 | Find All Duplicates | Array, Hash Table | ||
0443 | String Compression | Two Pointers, String | ||
0445 | Add Two Numbers II | Linked List, Math, Stack | ||
0448 | Find All Numbers Disappeared in an Array | Array, Hash Table | ||
0461 | Hamming Distance | Bit Manip | ||
0463 | Island Perimeter | Array, Depth-First Search, Breadth-First Search, Matrix | ||
0476 | Number Complement | Bit Manip | ||
0482 | License Key Formatting | String | ||
0485 | Max Consecutive Ones | Array | ||
0492 | Construct the Rectangle | Math | ||
0498 | Diagonal Traverse | Array, Matrix, Simulation | ||
0502 | IPO | Array, Greedy, Sorting, Heap (Priority Queue) | ||
0504 | Base 7 | Math | ||
0506 | Relative Ranks | Array, Sorting, Heap | ||
0507 | Perfect Number | Math | ||
0509 | Fibonacci Number | Math, Recursion, Dynamic Programming, Memoization | ||
0516 | Longest Palindromic Subsequence | String, DP | ||
0518 | Coin Change 2 | Array, DP | ||
0530 | Minimum Absolute Difference in BST | Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree | ||
0540 | Single Element in a Sorted Array | Array, BS | ||
0541 | Reverse String II | Two Pointers, String | ||
0543 | Diameter of Binary Tree | Tree, Depth First Search, Binary Tree | ||
0605 | Can Place Flowers | Array, Greedy | ||
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 | ||
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 | ||
0771 | Jewels and Stones | String, Hashtable | ||
0799 | Minimum Distance Between BST Nodes | Tree, Depth-First Search, Breadth-First Search, Binary Search Tree, Binary Tree | ||
0875 | Koko Eating Bananas | Array, BS | ||
0876 | Middle of the Linked List | Linked List, Two Pointers | ||
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 | ||
0958 | Check Completeness of a Binary Tree | Tree, Breadth-First Search, Binary Tree | ||
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 | ||
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 | ||
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 | ||
1461 | Check If a String Contains All Binary Codes of Size K | String, Hash Table, Bit Manipulation | ||
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 Pointer, 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 | ||
1630 | Count Odd Numbers in an Interval Range | Math | ||
1672 | Richest Customer Wealth | Array, Matrix | ||
1689 | Partitioning Into Minimum Number Of Deci-Binary Numbers | String, Greedy | ||
1920 | Build Array from Permutation | Array, Simulation | ||
1929 | Concatenation of Array | Array | ||
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 | ||
2160 | Minimum Sum of Four Digit Number After Splitting Digits | Math, Greedy, Sorting | ||
2176 | Count Equal and Divisible Pairs in an Array | Array | ||
2187 | Minimum Time to Complete Trips | Array, BS | ||
2235 | Add Two Integers | Math | ||
2236 | Root Equal to Sum of Children | Tree, Binary Tree | ||
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 | ||
2444 | Count Subarrays With Fixed Bounds | Array, Queue, Sliding Window, Monotonic Queue | ||
2469 | Convert the Temperature | Math | ||
2551 | Put Marbles in Bags | Array, Greedy, Sorting, Heap (Priority Queue) | ||
2574 | Left and Right Sum Differences | Array, Prefix Sum |