/LeetCode-record

My solutions for LeetCode problems

Primary LanguagePython

LeetCode-record

Introduction

My solutions for LeetCode problems

Problem List

ID Title Solution Difficulty Comments
5 Longest Palindromic Substring Python3 Medium Many solutions here
19 Remove Nth Node From End of List Python3 Medium
24 Swap Nodes in Pairs Python3 Medium
33 Search in Rotated Sorted Array Python3 Medium
34 Find First and Last Position of Element in Sorted Array Python3 Medium
35 Search Insert Position Python3 Easy
38 Count and Say Python3 Easy
49 Group Anagrams Python3 Medium
61 Rotate List Python3 Medium
69 Sqrt(x) Python3 Easy
74 Search a 2D Matrix Python3 Medium
82 Remove Duplicates from Sorted List II Python3 Medium
83 Remove Duplicates from Sorted List Python3 Easy
84 Largest Rectangle in Histogram Python3 Hard
85 Maximal Rectangle Python3[1, 2] Hard
92 Reverse Linked List II Python3 Medium
94 Binary Tree Inorder Traversal Python3 Medium
95 Unique Binary Search Trees II Python3 Medium Refer to here
96 Unique Binary Search Trees Python3 Medium
97 Interleaving String Python3 Hard
98 Validate Binary Search Tree Python3[1, 2] Medium Solution 2 refers to here
99 Recover Binary Search Tree Python3 Hard Refer to this thinking
100 Same Tree Python3 Easy
101 Symmetric Tree Python3[1, 2] Easy I think it should be Medium
102 Binary Tree Level Order Traversal Python3 Medium
103 Binary Tree Zigzag Level Order Traversal Python3 Medium Similar with 102
104 Maximum Depth of Binary Tree Python3 Easy
105 Construct Binary Tree from Preorder and Inorder Traversal Python3 Medium
106 Construct Binary Tree from Inorder and Postorder Traversal Python3 Medium
107 Binary Tree Level Order Traversal II Python3 Easy Similar with 102
108 Convert Sorted Array to Binary Search Tree Python3 Easy
109 Convert Sorted List to Binary Search Tree Python3 Medium
110 Balanced Binary Tree Python3 Easy
111 Minimum Depth of Binary Tree Python3 Easy A little entrap
116 Populating Next Right Pointers in Each Node Python3 Medium
146 LRU Cache Python3[1, 2] Hard Solution2 use OrderedDict
151 Reverse Words in a String Python3 Medium Maybe it is 'Easy'.
153 Find Minimum in Rotated Sorted Array Python3 Medium
160 Intersection of Two Linked Lists Python3 Easy Refer to here, two pointer solution
165 Compare Version Numbers Python3 Medium
168 Excel Sheet Column Title Python3 Easy *Recursion. It is more than 'Easy'!
172 Factorial Trailing Zeroes Python3 Easy There's a conclusion about factorial
206 Reverse Linked List Python3 Easy
236 Lowest Common Ancestor of a Binary Tree Python3 Medium
237 Delete Node in a Linked List Python3 Easy
257 Binary Tree Paths Python3 Easy
283 Move Zeroes Python3 Easy
301 Remove Invalid Parentheses Python3 Hard
330 Patching Array Python3 Hard Greedy, refer to here
341 Flatten Nested List Iterator Python3 Medium
378 Kth Smallest Element in a Sorted Matrix Python3 Medium Binary Search
395 Longest Substring with At Least K Repeating Characters Python3 Medium Divide and Conquer
414 Third Maximum Number Python3[1, 2] Easy
433 Minimum Genetic Mutation Python3 Medium Breadth-first Search
435 Non-overlapping Intervals C++ Medium Greedy
463 Island Perimeter Python3 Easy
468 Validate IP Address Python3 Medium
473 Matchsticks to Square Python3, C++ Medium Refer to official solution
522 Longest Uncommon Subsequence II Python3 Medium
543 Diameter of Binary Tree Python3 Easy
600 Non-negative Integers without Consecutive Ones Python3 Hard Dynamic programming, bit dp
647 Palindromic Substrings Python3[1, 2] Medium Solution 2 refers to here
665 Non-decreasing Array Python3 Easy
695 Max Area of Island Python3 Medium
773 Sliding Puzzle Python3 Hard
793 Preimage Size of Factorial Zeroes Function Python3 Hard Refer to here
797 All Paths From Source to Target Python3 Medium
802 Find Eventual Safe States Python3 Medium Refer to here
805 Split Array With Same Average Python3 Hard Refer to here
825 Friends Of Appropriate Ages Python3[1, 2] Medium Solution 2 refers to here
851 Loud and Rich Python3 Medium Depth-first
855 Exam Room C++ Medium Refer to here
876 Middle of the Linked List Python3 Easy
880 Decoded String at Index Python3[1, 2] Medium Solution 2 refers to here
893 Groups of Special-Equivalent Strings Python3 Easy Refer to here
898 Bitwise ORs of Subarrays Python3[1, 2] Medium Solution 2 refers to here
929 Unique Email Addresses Python3 Easy
954 Array of Doubled Pairs Python3 Medium
967 Numbers With Same Consecutive Differences Python3 Medium
1005 Maximize Sum Of Array After K Negations Python3 Easy
1006 Clumsy Factorial Python3 Medium
1007 Minimum Domino Rotations For Equal Row Python3 Medium
1008 Construct Binary Search Tree from Preorder Traversal Python3 Medium
1037 Valid Boomerang C++ Easy
1275 Find Winner on a Tic Tac Toe Game Python3 Easy
1276 Number of Burgers with No Waste of Ingredients Python3 Medium It should be Easy
1277 Count Square Submatrices with All Ones Python3 Medium DP Algorithm
1281 Subtract the Product and Sum of Digits of an Integer Python3 Easy
1282 Group the People Given the Group Size They Belong To Python3[1, 2] Medium Solution2 uses HashMap, refer to here
1283 Find the Smallest Divisor Given a Threshold Python3 Medium
1284 Minimum Number of Flips to Convert Binary Matrix to Zero Matrix Python3 Hard Enumeration Method
1290 Convert Binary Number in a Linked List to Integer Python3 Easy
1291 Sequential Digits Python3 Medium Enumeration
1292 Maximum Side Length of a Square with Sum Less than or Equal to Threshold Python3[1, 2] Medium Solution 2 uses a tricky optimization, refers to here
1293 Shortest Path in a Grid with Obstacles Elimination Python3[1, 2] Hard Solution 1 is DFS+pruning, solution 2 refers to here
1323 Maximum 69 Number CPP
1328 Break a Palindrome Python3 Medium
1329 Sort the Matrix Diagonally Python3 Medium
1330 Reverse Subarray To Maximize Array Value Python3[1, 2] Hard Solution 1 refers to here
1331 Rank Transform of an Array Python3 Easy
1332 Remove Palindromic Subsequences Python3 Easy puzzling
1333 Filter Restaurants by Vegan-Friendly, Price and Distance Python3 Medium
1334 Find the City With the Smallest Number of Neighbors at a Threshold Distance Python3 Medium
1335 Minimum Difficulty of a Job Schedule Python3 Hard DFS+Memoization
1341 The K Weakest Rows in a Matrix Python3 Easy
1342 Reduce Array Size to The Half Python3 Medium
1343 Maximum Product of Splitted Binary Tree Python3 Medium
DFS+Memoization1344 Jump Game V Python3 Hard DFS+Memoization
1346 Check If N and Its Double Exist Python3 Easy
1347 Minimum Number of Steps to Make Two Strings Anagram Python3 Medium
1348 Tweet Counts Per Frequency Python3 Medium
1349 Maximum Students Taking Exam Python3 Hard State compression DP, refer to here
1351 Count Negative Numbers in a Sorted Matrix Python3 Easy
1352 Product of the Last K Numbers Python3 Medium refer to here
1353 Maximum Number of Events That Can Be Attended Python3 Medium Greedy, refer to here
1354 Construct Target Array With Multiple Sums Python3 Hard
1360 Number of Days Between Two Dates Python3 Easy
1361 Validate Binary Tree Nodes Python3 Medium
1362 Closest Divisors Python3 Medium
1389 Create Target Array in the Given Order Python3 Easy
1390 Four Divisors Python3 Medium
1391 Check if There is a Valid Path in a Grid Python3 Medium
1392 Longest Happy Prefix Python3 Hard
5291 Find Numbers with Even Number of Digits Python3 Easy
5292 Divide Array in Sets of K Consecutive Numbers Python3 Medium
5293 Maximum Number of Occurrences of a Substring Python3 [1, 2] Medium Solution 2 uses sliding window and unordered dict, which is faster. Refer to here
5294 Maximum Candies You Can Get from Boxes Python3 [1, 2] Hard Solution uses BFS, refer to here