Skip to content

Latest commit

 

History

History
419 lines (410 loc) · 51 KB

README.md

File metadata and controls

419 lines (410 loc) · 51 KB
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

# 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 LL, Recursion
0022 Generate Parentheses String, DP, 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 2P, 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, 2P, DP, ST, Monotonic Stack
0048 Rotate Image Array, Math, Matrix
0051 N-Queens Array, Backtracking
0053 Maximum Subarray Array, DNC, DP
0055 Jump Game Array, DP, 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 Manip, Simulation
0069 Sqrt(x) Math, BS
0070 Climbing Stairs Math, DP, Memorization
0072 Edit Distance String, DP
0074 Search a 2D Matrix Array, BS, 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, 2P, Sorting
0094 Binary Tree Inorder Traversal Tree, Stack, DFS, Binary Tree
0098 Validate BST Tree, DFS, BST, Binary Tree
0100 Same Tree Tree, DFS, BFS, Binary Tree
0101 Symmetric Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree
0103 Binary Tree Zigzag Level Order Traversal Tree, BFS, Binary Tree
0104 Maximum Depth of Binary Tree Tree, BFS, DFS, Binary Tree
0106 Construct Binary Tree from Inorder and Postorder Traversal Array, Hash Table, DNC, Tree, Binary Tree
0108 Convert Sorted Array to Binary Search Tree Array, DNC, Tree, BST, Binary Tree
0109 Convert Sorted List to Binary Search Tree LL, DNC, Tree, BST, Binary Tree
0110 Balanced Binary Tree Tree, DFS, Binary Tree
0111 Minimum Depth of Binary Tree Tree, DFS, BFS, 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, DP, Greedy
0125 Valid Palindrome 2P, 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, LL, 2P
0142 Linked List Cycle II Hash Table, LL, 2P
0144 Binary Tree Preorder Traversal Stack, Tree, DFS, Binary Tree
0145 Binary Tree Postorder Traversal Stack, Tree, DFS, Binary Tree
0160 Intersection of Two Linked Lists Hash Table, LL, 2P
0169 Majority Element Array, Hash Table, DNC, Sorting, Counting
0172 Factorial Trailing Zeroes Math
0190 Reverse Bits DNC, 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, DFS, BFS, 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 LL, 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, DFS, Binary Tree
0225 Implement Stack using Queues ST, 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, DFS, BST, Binary Tree
0231 Power of Two Math, Bit Manipulation, Recursion
0232 Implement Queue using Stacks ST, Design, Q
0234 Palindrome Linked List LL, 2P, ST, 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, BS, Bit Manip, Sorting
0278 First Bad Version Binary Search, Interactive
0279 Perfect Squares Math, DP, 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, DP, BFS
0326 Power of Three Math, Recursion
0337 House Robber III DP, Tree, DFS, Binary Tree
0338 Counting Bits DP, Bit Manip
0342 Power of Four Math, Bit Manip, Recursion
0344 Reverse String Two Pointers, String, Recursion
0345 Reverse Vowels of a String 2P, String
0349 Intersection of Two Arrays Array, Hash Table, 2P, BS, Sorting
0350 Intersection of Two Arrays II Array, Hash Table, 2P, BS, Sorting
0367 Valid Perfect Square Math, Binary Search
0369 Plus One Linked List Linked List, Math 🔒
0374 Guess Number Higher or Lower BS, Interactive
0382 Linked List Random Node LL, Math, Reservoir Sampling, Randomized
0383 Ransom Note Hash Table, String, Counting
0387 First Unique Character in a String Hash Table, String, Q, Counting
0389 Find the Difference Hash Table, String, Bit Manipulation, Sorting
0392 Is Subsequence 2P, 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 2P, 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, DP, 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, BST, Binary Tree
0540 Single Element in a Sorted Array Array, BS
0541 Reverse String II Two Pointers, String
0543 Diameter of Binary Tree Tree, DFS, 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, DFS, BST, 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, BST, 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, DNC, 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, LL, ST, 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, DP, 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, 2P, Brainteaser
2413 Smallest Even Multiple Math, Number Theory
2427 Number of Common Factors Math, Enumeration, Number Theory
2444 Count Subarrays With Fixed Bounds Array, Q, 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