Skip to content

Latest commit

 

History

History
249 lines (243 loc) · 52.7 KB

README.md

File metadata and controls

249 lines (243 loc) · 52.7 KB

LeetCode Solution

Records of all my solved problems on LeetCode

Question # Solution Link Difficulty Category Demo Language LeetCode Link
1 twoSum Easy HashMap False Java Two Sum
2 addTwoNums Medium Math False Java Add Two Numbers
3 lenOfLongestSubstr Medium Sliding Window True Java Longest Substring Without Repeating Characters
4 medianOf2SortedAry Hard Binary Search True Java Median of Two Sorted Arrays
5 longestPalindrome Medium Dynamic Programming True Java Longest Palindromic Substring
6 zigzagConversion Medium Str Traversal True Java ZigZag Conversion
7 reverseInteger Easy Math False Java Reverse Integer
8 atoi Medium Str Traversal, DFA True Java String to Integer (atoi)
9 palindromeNum Easy Math False Java Palindrome Number
10 regExpMatching Hard Dynamic Programming True Java Regular Expression Matching
11 maxArea Medium Two Pointers True Java Container With Most Water
12 intToRoman Medium Math False Java Integer to Roman
13 romanToInt Easy Math False Java Roman to Integer
14 lngstCommonPrefix Easy Str Traversal False Java, Python Longest Common Prefix
15 threeSum Medium Two Pointers False Python 3Sum
16 threeSumClosest Medium Two Pointers False Python 3Sum Closest
17 phoneNumLetterComb Medium Math True Python Letter Combinations of a Phone Number
18 fourSum Medium Two Pointers, Recursion False Python 4Sum
19 rmNthNodeFromEnd Medium LinkedList True Java Remove Nth Node From End of List
20 validParentheses Easy Stack, Turing Machine True Python, Java Valid Parentheses
21 mergeTwoSortedArys Easy LinkedList False Java Merge Two Sorted Lists
22 generateParentheses Medium Dynamic Programming, Backtracking True Python Generate Parentheses
23 mergeKsortedArys Hard Priority Queue, Divide & Conquer True Java Merge k Sorted Lists
24 swapPairs Medium LinkedList, Recursion False Java Swap Nodes in Pairs
25 reverseKgroup Hard LinkedList True Java Reverse Nodes in k-Group
26 rmDuplicatesFromList Easy Two Pointers False Python Remove Duplicates from Sorted Array
27 rmElementsFromList Easy Two Pointers False Python Remove Element
28 implementIndexOf Easy Sliding Window, Two Pointers True Python Implement strStr()
29 divideTwoInts Medium Bit Manipulation False Java Divide Two Integers
30 findSubstr Hard HashMap True Python Substring with Concatenation of All Words
31 nextPermutation Medium Math True Python Next Permutation
32 lngstValidParentheses Hard Stack, Dynamic Programming True Python Longest Valid Parentheses
33 searchRotatedSortedAry Medium Binary Search True Python Search in Rotated Sorted Array
34 searchRangeInSortedAry Medium Binary Search False Python Find First and Last Position of Element in Sorted Array
35 searchInsertPos Easy Binary Search False Python Search Insert Position
36 validSudoku Medium HashSet False Python Valid Sudoku
37 solveSudoku Hard Backtracking False Python Sudoku Solver
38 countAndSay Medium Str Traversal True Java Count and Say
39 combinationSum Medium Backtracking, Dynamic Programming True Java Combination Sum
40 combinationSum II Medium Backtracking, Dynamic Programming False Java Combination Sum II
41 firstMissingPositive Hard In-place Hashing True Java First Missing Positive
42 trappingRainWater Hard Dynamic Programming True Java, Python Trapping Rain Water
43 multiplyStrings Medium Math True Python Multiply Strings
44 wildcardMatching Hard Backtracking, Dynamic Programming True Python Wildcard Matching
45 jumpGame2 Medium Greedy Algorithm True Java Jump Game II
46 permutations Medium DFS True Python, C++ Permutations
47 permutations2 Medium DFS False Python Permutations II
48 rotateImage Medium List Manipulation True Python Rotate Image
49 groupAnagrams Medium HashMap False Python Group Anagrams
50 pow(x, n) Medium Binary Exponentiation True Python Pow(x, n)
51 n-queens Hard Backtracking False Python N-Queens
52 n-queens 2 Hard Backtracking False Python N-Queens II
53 maximumSubarray Easy Dynamic Programming True Java Maximum Subarray
54 spiralMatrix Medium List Traversal False Python Spiral Matrix
55 jumpGame Medium Greedy Algorithm, Backtracking False Python Jump Game
56 mergeIntervals Medium List Traversal False Python Merge Intervals
57 insertIntervals Medium List Traversal False Python Insert Interval
58 lengthOfLastWord Easy Str Traversal False Python Length of Last Word
59 spiralMatrix II Medium List Traversal False Python Spiral Matrix II
60 permutationSeq Hard Math True Python Permutation Sequence
61 rotateList Medium LinkedList False Python Rotate List
62 uniquePaths Medium DFS, Recursion False Python Unique Paths
63 uniquePaths II Medium Dynamic Programming True Python Unique Paths II
64 minPathSum Medium Dynamic Programming False Python Minimum Path Sum
65 validNumber Hard DFA True Python Valid Number
66 plusOne Easy Math False Python Plus One
67 addBinary Easy Math False Python Add Binary
68 textJustification Hard List Traversal False Python Text Justification
69 sqrt(x) Easy Math False Python Sqrt(x)
70 climbStairs Easy Math False Python Climbing Stairs
71 simplifyPath Medium Str Traversal False Python Simplify Path
72 editDistance Hard Dynamic Programming True Python Edit Distance
73 setMatrixZero Medium List Traversal True Python Set Matrix Zeroes
74 searchMatrix Medium Binary Search, List Traversal False Python Search a 2D Matrix
75 sortColors Medium Two Pointers, Sorting False Python Sort Colors
76 minWindow Hard Two Pointers False Python Minimum Window Substring
77 combinations Medium Backtracking False Python Combinations
78 subsets Medium Backtracking, Cascading True Python Subsets
79 wordSearch Medium Backtracking False Python Word Search
80 rmDupFromSortedAry II Medium Two Pointers True Python Remove Duplicates from Sorted Array II
81 searchRotatedSortedAry II Medium Binary Search False Python Search in Rotated Sorted Array II
82 rmDupFromSortedLst II Medium Two Pointers False Python Remove Duplicates from Sorted List II
83 rmDupFromSortedLst Easy LinkedList, Recursion True Python Remove Duplicates from Sorted List
84 largestRecInHist Hard Stack False Python Largest Rectangle in Histogram
85 maxRec Hard Dynamic Programming False Python Maximal Rectangle
86 partitionList Medium LinkedList, Two Pointers False Python Partition List
87 scrambleString Hard Recursion True Python Scramble String
88 mergeSortedAry Easy List Traversal False Python Merge Sorted Array
89 grayCode Medium Bit Manipulation False Python Gray Code
90 subsets II Medium DFS False Python Subsets II
91 decodeWays Medium DFS, Dynamic Programming True Python Decode Ways
92 reverseLinkedList II Medium LinkedList False Python Reverse Linked List II
93 restoreIPaddr Medium Backtracking False Python Restore IP Addresses
94 inorderTraversal Easy Binary Tree, DFS True Python Binary Tree Inorder Traversal
95 uniqueBST II Medium Binary Tree, Recursion True Python Unique Binary Search Trees II
96 uniqueBST Medium Dynamic Programming, Binary Tree True Python Unique Binary Search Trees
97 interleavingStr Medium Dynamic Programming, Backtracking, DFS False Python Interleaving String
98 validateBST Medium DFS, BFS, BST False Python Validate Binary Search Tree
99 recoverBST Medium DFS, BST False Python Recover Binary Search Tree
100 sameTree Medium DFS, BST False Python Same Tree
101 symmetricTree Easy DFS, BST False Python Symmetric Tree
102 levelOrderTraversal Mediumn BFS, BST False Python Binary Tree Level Order Traversal
103 BTzigzagTraversal Mediumn BFS, BST False Python Binary Tree Zigzag Level Order Traversal
104 maxDepthBST Easy DFS, BST False Python Maximum Depth of Binary Tree
105 treeFromPre&Inorder Medium BST False Python Construct Binary Tree from Preorder and Inorder Traversal
106 treeFromIn&Postorder Medium BST False Python Construct Binary Tree from Inorder and Postorder Traversal
107 lvlOrderTraversal II Medium BFS, BST False Python Binary Tree Level Order Traversal II
108 cvtSortedAryToBST Easy BST False Python Convert Sorted Array to Binary Search Tree
109 cvtSortedLnkedListToBST Medium BST False Python Convert Sorted List to Binary Search Tree
110 balancedBinaryTree Easy DFS False Python Balanced Binary Tree
111 minDepthOfBinaryTree Easy DFS False Python Minimum Depth of Binary Tree
112 pathSum Easy DFS False Python Path Sum
113 pathSum II Medium DFS False Python Path Sum II
114 flattenBT2LinkedList Medium Binary Tree True Python Flatten Binary Tree to Linked List
115 distinctSubseq Hard DFS, Dynamic Programming False Python Distinct Subsequences
116 populatingNextPtr Medium BFS False Python Populating Next Right Pointers in Each Node
117 populatingNxtPtr II Medium BFS False Python Populating Next Right Pointers in Each Node II
118 Pascal's triangle Easy Math False Python Pascal's Triangle
119 Pascal's triangle II Easy Math False Python Pascal's Triangle II
120 minTotalTriangle Medium Dynamic Programming True Python Triangle
121 bestTimeToBuyAndSell Easy Two Pointers True Python Best Time to Buy and Sell Stock
122 bestTimeToBuyAndSell II Medium Greedy Algorithm True Python Best Time to Buy and Sell Stock II
123 bestTimeToBuyAndSell III Hard Dynamic Programming False Python Best Time to Buy and Sell Stock III
124 BTMaxPathSum Hard Recursion False Python Binary Tree Maximum Path Sum
125 validPalindrome Easy Two Pointers False Python Valid Palindrome
126 wordLadder II Hard BFS False Python Word Ladder II
127 wordLadder Hard BFS, Bidirectional BFS True Python Word Ladder
128 longestConsecutiveSeq Medium List Traversal True Python Longest Consecutive Sequence
129 root2LeafNumSum Medium DFS False Python, C++ Sum Root to Leaf Numbers
130 surroundedRegions Medium DFS False C++ Surrounded Regions
131 partitionPalindrome Medium DFS, Backtracking True C++ Palindrome Partitioning
132 partitionPalindromeII Hard Dynamic Programming True C++ Palindrome Partitioning II
133 cloneGraph Medium DFS False C++ Clone Graph
134 gasStation Medium Greedy False C++ Gas Station
135 candy Hard Greedy False C++ Candy
136 singleNumber Easy Bit Manipulation False C++ Single Number
137 singleNumber II Medium Bit Manipulation, Logic Circuit True C++ Single Number II
138 copyLstW/RandomPtr Medium LinkedList, Map True C++ Copy List with Random Pointer
139 wordBreak Medium Dynamic Programming True C++ Word Break
140 wordBreak II Hard Backtracking False C++ Word Break II
141 linkedListCycle Easy LinkedList False C++ Linked List Cycle
142 linkedListCycle II Medium Two Pointers, LinkedList True C++ Linked List Cycle II
143 reorderList Medium Two Pointers, LinkedList False C++ Reorder List
144 preorderTraversal Easy Recursion, Morris Traversal, Stack True C++ Binary Tree Preorder Traversal
145 postorderTraversal Easy Recursion, Stack False C++ Binary Tree Postorder Traversal
146 LRUCache Medium LinkedList False C++ LRUCache
147 insertionSortList Medium LinkedList False C++ Insertion Sort List
148 sortList Medium Merge Sort, LinkedList False C++ Sort List
149 maxPtsOnLine Hard Math False Python Max Points on a Line
150 evalRevPolishNotation Medium Stack False Python Evaluate Reverse Polish Notation
151 reverseWordsInStr Medium Str Manipulation True C++ Reverse Words in a String
152 maxProductSubarray Medium Dynamic Programming False Python Maximum Product Subarray
153 findMinInRotatedSortedAry Medium Binary Search False Python Find Minimum in Rotated Sorted Array
154 findMinInRotatedSortedAry II Hard Binary Search False Python Find Minimum in Rotated Sorted Array II
155 minStack Medium Stack False Python Min Stack
160 intersecionOf2LL Easy LinkedList False Python Intersection of Two Linked Lists
162 findPeakElement Medium Binary Search False Python Find Peak Element
164 maxGap Hard Bucket Sort False Python Maximum Gap
165 compareVersionNums Medium List Traversal False Python Compare Version Numbers
166 fractionToDecimal Medium Math True Python Fraction to Recurring Decimal
167 twoSum II Medium Two Pointers False Python Two Sum II - Input Array Is Sorted
168 excelSheetColTitle Easy Math False Python Excel Sheet Column Title
169 majorityElement Easy List Traversal False Python Majority Element
171 excelSheetColNum Easy Math True Python, C++ Excel Sheet Column Number
172 factorialTrailingZeroes Medium Math False Python Factorial Trailing Zeroes
173 BSTIterator Medium BST False Python Binary Search Tree Iterator
174 dungeonGame Hard Dynamic Programming False Python Dungeon Game
175 combineTwoTables Easy SQL False SQL Combine Two Tables
176 secondHighestSalary Medium SQL False SQL Second Highest Salary
177 NthHighestSalary Medium SQL False SQL Nth Highest Salary
178 rankScores Medium SQL False SQL Rank Scores
179 largestNumber Medium Sorting False Python Largest Number
180 consecutiveNumbers Medium SQL False SQL Consecutive Numbers
181 employeeWithHigherSalary Easy SQL False SQL Employees Earning More Than Their Managers
182 duplicateEmails Easy SQL False SQL Duplicate Emails
183 customersWithoutOrders Easy SQL False SQL Customers Who Never Order
184 departmentHighestSalary Medium SQL False SQL Department Highest Salary
185 departmentTop3Salaries Hard SQL False SQL Department Top Three Salaries
187 repeatedDNASequences Medium Sliding Window False Python Repeated DNA Sequences
188 bestTimeToBuyAndSell IV Hard Dynamic Programming False Python Best Time to Buy and Sell Stock IV
189 rotateArray Medium Array False Python Rotate Array
190 reverseBits Easy Bit Manipulation False Python Reverse Bits
191 1BitsCount Easy Bit Manipulation False Python Number of 1 Bits
198 houseRobber Medium Dynamic Programming False Python House Robber
200 numIslands Medium DFS False Python Number of Islands
206 reverseLinkedList Easy LinkedList True Python Reverse Linked List
208 Trie Medium Trie False C++ Implement Trie (Prefix Tree)
213 houseRobber 2 Medium Dynamic Programming True C++ House Robber II
215 kthLargestElementInAry Medium Quickselect True Python Kth Largest Element in an Array
221 maxSquare Medium Dynamic Programming False Python Maximal Square
290 wordPattern Easy HashMap False Python, C++ Word Pattern
322 coinChange Medium DFS, Dynamic Programming False C++ Coin Change
332 reconstructIternary Hard Stack, Backtracking False Python Reconstruct Itinerary
337 houseRobber 3 Medium DFS Memorization False C++ House Robber III
359 loggerRateLimiter Easy Hash False Python Logger Rate Limiter
366 findLeavesOfBST Medium Binary Tree, DFS False Python Find Leaves of Binary Tree
418 screenSentenceFitting Medium List Traversal False Python Sentence Screen Fitting
450 deleteNodeInBST Medium BST False Python Delete Node in a BST
678 validParenthesisStr Medium DFS, Dynamic Programming, Greedy False Python Valid Parenthesis String
690 employeeImportance Easy BFS, DFS False Python Employee Importance
696 countBinarySubstr Easy Two Pointers True Python Count Binary Substrings
735 asteroidCollision Medium Stack False Python Asteroid Collision
753 crackSafe Hard Backtracking, Hierholzer Algorithm, Eulerian Cycle True C++ Cracking the Safe
787 cheapestFlights Medium Bellman Ford's Algorithm, Dijkstra's Algorithm, Dynamic Programming False C++ Cheapest Flights Within K Stops
792 numOfMatchingSubseq Medium Binary Search, Pointer False Python Number of Matching Subsequences
833 find&ReplaceInStr Medium String Manipulation False Python Find And Replace in String
843 guessWord Hard Game Theory False Python Guess the Word
853 carFleet Medium List Traversal False Python Car Fleet
923 threeSumMulti Medium Two Pointers, Math True C++ 3Sum With Multiplicity
931 minFallingPathSum Medium Dynamic Programming False Python Minimum Falling Path Sum
981 timeBasedKeyValStore Medium Binary Search False Python Time Based Key-Value Store
983 minCostsForTickets Medium Dynamic Programming, DFS False Python Minimum Cost For Tickets
1004 maxConsecutiveOnes III Medium Sliding Window False Python Max Consecutive Ones III
1048 longestStrChain Medium Dynamic Programming, DFS False Python Longest String Chain
1110 delNodes&ReturnForest Medium DFS False Python Delete Nodes And Return Forest
1146 snapshotArray Medium Binary Search False Python Snapshot Array
1278 palindromePartitioning III Hard Dynamic Programming, DFS Memorization True C++ Palindrome Partitioning III
1423 maxPointsFromCards Medium Sliding Window, Two Pointers False Python Maximum Points You Can Obtain from Cards
1428 minDaysBloom Medium Binary Search False Python Minimum Number of Days to Make m Bouquets
1509 minDiffBetMax&Min Medium Backtracking False Python Minimum Difference Between Largest and Smallest Value in Three Moves
1525 numOfWaysToSplitStr Medium HashMap False Python Number of Good Ways to Split a String
1526 minNumOfIncrement Hard Dynamic Programming True Python Minimum Number of Increments on Subarrays to Form a Target Array
1548 mostSimilarPath Hard Dynamic Programming True Python The Most Similar Path in a Graph
1610 maxNumVisiblePts Hard Sliding Window, Geometry False Python Maximum Number of Visible Points
1776 carFleet II Hard Stack, Monotonic Stack False Python Car Fleet II
1834 singleThreadedCPU Medium Min-Heap, Priority Queue False C++ Single-Threaded CPU
1937 maxPointsWithCost Medium Dynamic Programming False Python Maximum Number of Points with Cost

Other Questions

Question Solution Link Category Demo Language
Permutation of if-blocks ifBlockPermutations DFS, Backtracking False Python
Image Matching imageMatching Stack, DFS False Python
Remove B removeB DFS False Python
Inversion Inversion Dynamic Programming, Backtracking False Python
Shortest Rainbow Path shortestRainbowPath Dijkstra's algorithm False Python
Knapsack Problem knapsack Genetic Algorithm, Dynamic Programming False Python, C++
Min Health getMinHealth Priority Queue False Python
Visiting Cities minCost Dynamic Programming False Python