LeetCode solutions and thoughts in python under random sequence.
For daily practice.
Those questions with stars at the end were faced during one or more interviews by myself from autumn 2018 to spring 2019.
| Index | Title | Solution | Difficulty | Keywords | Star |
|---|---|---|---|---|---|
| 1 | Two Sum | Python | Easy | Array; Dual Pointer; Hash Table | * |
| 2 | Add Two Numbers | Python | Medium | Linked List | |
| 3 | Length of Longest Subsrting | Python | Medium | Hash Table | |
| 4 | Median of Two Sorted Arrays | Python | Hard | Binary Search(expected) | |
| 5 | Longest Palindromic Substring | Python | Medium | String | |
| 6 | Zigzag Conversion | Python | Medium | String | |
| 7 | Reverse Integer | Python | Easy | String | |
| 9 | Palindrome Number | Python | Easy | String | |
| 11 | Container with Most Water | Python | Medium | Array; Dual Pointer | |
| 14 | Longest Common Prefix | Python | Easy | String | |
| 15 | Three Sum | Python | Medium | Array; Dual Pointer | |
| 16 | 3Sum Closest | Python | Medium | Array; Dual Pointer | |
| 17 | Letter Combinations of a Phone Number | Python | Medium | Backtrack | |
| 19 | Remove Nth Node from End of List | Python | Medium | Linked List; Dual Pointer | |
| 20 | Valid Parentheses | Python | Easy | Stack | |
| 21 | Merge Two Sorted Lists | Python | Easy | Linked List | |
| 23 | Merge K Sorted Lists | Python | Hard | Linked List | |
| 24 | Swap Nodes In Pairs | Python | Medium | Linked List | |
| 26 | Remove Duplicates from Sorted Array | Python | Easy | Dual Pointer | |
| 26 | Remove Element | Python | Easy | Dual Pointer | |
| 28 | Implement strStr() | Python | Easy | String | |
| 30 | Substring With Concatenation of All Words | Python | Hard | Sliding Window; Hash Table | |
| 31 | Next Permutation | Python | Medium | String | |
| 33 | Search in Rotated Sorted Array | Python | Medium | Binary Search | |
| 34 | Find First and Last Position of Element in Sorted Array | Python | Medium | Binary Search | |
| 35 | Search Insert Position | Python | Easy | Binary Search | |
| 36 | Valid Sudoku | Python | Medium | Array | |
| 39 | Combination Sum | Python | Medium | Backtrack; DFS | |
| 40 | Combination Sum II | Python | Medium | Backtrack; DFS | |
| 42 | Trapping Rain Water | Python | Hard | Array;Dual Pointer(Expected);Stack(Expected) | |
| 46 | Permutation | Python | Medium | Recursion | |
| 47 | Permutation II | Python | Medium | Recursion | |
| 48 | Rotate Image | Python | Medium | Matrix | |
| 49 | Group Anagrams | Python | Medium | Hash Table | |
| 50 | Pow(x,n) | Python | Medium | Binary Search; Recursion | |
| 52 | N Queens ii | Python | Hard | Backtrack | |
| 53 | Maximum Subarray | Python | Easy | Dynamic Programming; Divide and Conquer | * |
| 54 | Spiral Matrix | Python | Medium | Array | |
| 55 | Jump Game | Python | Medium | Greedy Algorithm | |
| 56 | Merge Intervals | Python | Medium | Array | |
| 57 | Insert Intervals | Python | Medium | Array | |
| 58 | Length of Last Word | Python | Easy | String | |
| 59 | Spiral Matrix II | Python | Medium | Array | |
| 61 | Rotate List | Python | Medium | Linked List; Dual Pointer | |
| 62 | Unique Paths | Python | Medium | Dynamic Programming | |
| 63 | Unique Paths II | Python | Medium | Dynamic Programming | * |
| 64 | Minimum Paths Sum | Python | Medium | Dynamic Programming | |
| 66 | Plus One | Python | Easy | Array | |
| 69 | Sqrt() | Python | Easy | Binary Search | |
| 70 | Climbing Stairs | Python | Easy | Dynamic Programming | |
| 71 | Simplify Path | Python | Medium | Stack | |
| 72 | Edit Distance | Python | Easy | Dynamic Programming | |
| 73 | Set Matrix Zeroes | Python | Medium | Matrix | |
| 74 | Search a 2D Matrix | Python | Medium | Binary Search | |
| 75 | Sort Colors | Python | Medium | ||
| 78 | Subsets | Python | Medium | Array; DFS | |
| 79 | Word Search | Python | Medium | Array; DFS | |
| 80 | Remove Duplicates From Sorted Array II | Python | Medium | Array; Dual Pointer | |
| 82 | Remove Duplicates From Sorted Lists II | Python | Medium | Linked List | |
| 83 | Remove Duplicates From Sorted Lists | Python | Easy | Linked List | |
| 88 | Merge Sorted Array | Python | Easy | Array; Dual Pointer | |
| 89 | Gray Code | Python | Medium | ||
| 92 | Reverse Linked List II | Python | Medium | Linked List | |
| 94 | Binary Tree Inorder Traversal | Python | Medium | Binary Tree; Stack | |
| 97 | Interleaving String | Python | Medium | DP | |
| 98 | Validate Binary Search Tree | Python | Medium | BST | |
| 100 | Same Tree | Python | Easy | Tree | |
| 101 | Symmetric Tree | Python | Easy | Tree | |
| 102 | Binary Tree Level Order Traversal | Python | Medium | Tree | |
| 103 | Binary Tree Zigzag Level Order Traversal | Python | Medium | Tree; DFS | |
| 104 | Maximum Depth of Binary Tree | Python | Easy | Tree; Recursion | |
| 105 | Construct Binary Tree from Preorder and Inorder Traversal | Python | Medium | Tree; Recursion | |
| 106 | Construct Binary Tree from Inorder and Postorder Traversal | Python | Medium | Tree; Recursion | |
| 108 | Convert Sorted Array to Binary Search Tree | Python | Easy | Tree; Recursion | |
| 110 | Balanced Binary Tree | Python | Easy | Binary Tree | |
| 111 | Minimum Depth of Binary Tree | Python | Easy | Tree; Recursion | |
| 112 | Path Sum | Python | Easy | DFS | |
| 113 | Path Sum II | Python | Medium | Binary Tree; DFS | |
| 114 | Flatten Binary Tree to Linked List | Python | Medium | Binary Tree | |
| 116 | Populating Next Right Pointers in Each Node | Python | Medium | Binary Tree | |
| 117 | Populating Next Right Pointers in Each Node II | Python | Medium | Binary Tree | |
| 118 | Pascal Triangle I | Python | Easy | Array | |
| 119 | Pascal Triangle II | Python | Easy | Array | |
| 120 | Triangle | Python | Medium | Dynamic Programming | |
| 121 | Best Time to Buy and Sell Stock I | Python | Easy | Array; Dynamic Programming | |
| 122 | Best Time to Buy and Sell Stock II | Python | Easy | Array; Dynamic Programming; Greedy Algorithm | |
| 124 | binary-tree-maximum-path-sum | Python | Hard | Tree; DFS | |
| 125 | Valid Palindrome | Python | Easy | String | |
| 128 | Longest Consecutive Sequence | Python | Medium | Array | |
| 129 | Sum Root to Leaf Numbers | Python | Medium | DFS | |
| 130 | Surrounded Regions | Python | Medium | DFS | |
| 131 | Palindrome Partitioning | Python | Medium | DFS; Dynamic Programming | |
| 134 | Gas Station | Python | Medium | Greedy | |
| 135 | Candy | Python | Hard | Greedy | |
| 136 | Single Number | Python | Easy | XOR; Hash Table | |
| 137 | Single Number II | Python | Medium | Hash Table | |
| 139 | Word Break | Python | Medium | Dynamic Programming | |
| 141 | Linked List Cycle | Python | Easy | Linked List; Dual Pointer | |
| 142 | Linked List Cycle II | Python | Medium | Linked List; Dual Pointer | |
| 144 | Binary Tree Preorder Traversal | Python | Medium | Binary Tree; Stack | |
| 145 | Binary Tree Postorder Traversal | Python | Hard | Binary Tree; Stack | |
| 148 | Sort List | Python | Medium | Linked List; Merge Sort | |
| 149 | Max Points on a Line | Python | Hard | Hash Table | |
| 151 | Reverse Words in a String | Python | Medium | String | |
| 153 | Find Minimum in Rotated Sorted Array | Python | Medium | Binary Search | |
| 155 | Min Stack | Python | Easy | Stack | |
| 160 | Intersection of Two Linked Lists | Python | Easy | Linked List | |
| 162 | Find Peak Element | Python | Medium | Binary Search | |
| 167 | Two Sum II | Python | Easy | Dual Pointer | |
| 169 | Majority Element | Python | Easy | Array | |
| 171 | Excel Sheet Column Number | Python | Easy | String | |
| 172 | Factorial Trailing Zeroes | Python | Medium | Maths | |
| 173 | Binary Search Tree Iterator | Python | Medium | BST; Stack | |
| 175 | Combine Two Tables | Python | Easy | SQL; Pandas | |
| 176 | Second Highest Salary | Python | Medium | SQL; Pandas | |
| 176 | Nth Highest Salary | Python | Medium | SQL; Pandas | |
| 179 | Largest Number | Python | Medium | Sorting | |
| 187 | Repeated DNA Sequences | Python | Medium | String; Hash Table | |
| 189 | Rotate Array | Python | Easy | Array | |
| 198 | House Robber | Python | Easy | Dynamic Programming | |
| 199 | Binary Tree Right Side View | Python | Mediun | Tree; BFS | |
| 200 | Number of Islands | Python | Medium | DFS | |
| 202 | Happy Number | Python | Easy | Hash Table | |
| 203 | Remove Linked List Elements | Python | Easy | Linked List | |
| 205 | Isomorphic Strings | Python | Easy | Hash Table | |
| 206 | Reverse Linked List | Python | Easy | Linked List | * |
| 207 | course-schedule | Python | Medium | DFS | |
| 209 | Minimum Size Subarray Sum | Python | Medium | Array; Dual Pointer; Binary Search | |
| 213 | House Robber II | Python | Medium | Dynamic Programming | |
| 215 | Kth Largest Element in an Array | Python | Medium | Heap | * |
| 217 | Contains Duplicate | Python | Easy | Array; Hash Table | |
| 219 | Contains Duplicate II | Python | Easy | Array | |
| 220 | Contains Duplicate III | Python | Medium | BST | |
| 222 | Count Complete Tree Nodes | Python | Medium | Tree | |
| 226 | Invert Binary Tree | Python | Easy | Tree | |
| 228 | Summary Ranges | Python | Medium | Array; Dual Pointer | |
| 229 | Majority Element II | Python | Medium | Hash Table | |
| 230 | Kth Smallest Element in a BST | Python | Medium | BST | |
| 231 | Power of Two | Python | Easy | Maths | |
| 234 | Palindrome Linked List | Python | Easy | Linked List; Two Pointers | |
| 235 | Lowest Common Ancestor of a Binary Search Tree | Python | Medium | BST | |
| 236 | Lowest Common Ancestor of a Binary Tree | Python | Medium | Tree; Backtrack | * |
| 237 | Delete Node in a Linked List | Python | Easy | Linked List | |
| 238 | Product of Array Except Self | Python | Medium | Array | * |
| 240 | Search a 2D Matrix II | Python | Medium | Two Pointers; Binary Search(Expected) | |
| 242 | Valid Anagram | Python | Easy | Hash Table | |
| 257 | Binary Tree Paths | Python | Easy | Tree; DFS | |
| 260 | Single Number III | Python | Medium | Hash Table | |
| 263 | Ugly Number | Python | Easy | Math | |
| 268 | Missing Number | Python | Easy | Bitwise Operation | |
| 278 | First Bad Version | Python | Easy | Binary Search | |
| 283 | Move Zeros | Python | Easy | ||
| 284 | Peeking Iterator | Python | Medium | Designing | |
| 287 | Find the Duplicate Number | Python | Medium | Hash Table | |
| 289 | Game of Life | Python | Medium | Array | |
| 290 | Word Pattern | Python | Easy | Hash Table | |
| 292 | Nim Game | Python | Easy | Maths | |
| 299 | Bulls and Cows | Python | Medium | Hash Table | |
| 300 | Longest Increasing Subsequence | Python | Medium | Array; Dynamic Programming | |
| 309 | Best Time to Buy and Sell Stock with Cooldown | Python | Medium | Array; Dynamic Programming | |
| 316 | Remove Duplicate Letters | Python | Medium | Stack; Hash Table | |
| 322 | Coin Change | Python | Medium | Dynamic Programming | |
| 328 | Odd Even Linked List | Python | Medium | Linked List | |
| 334 | Increasing Triplet Subsequence | Python | Medium | Dynamic Programming(not expected) | |
| 337 | House Robber III | Python | Medium | Dynamic Programming; Binary Tree; DFS(Expected) | |
| 344 | Reverse String | Python | Easy | String; Recursion | |
| 345 | Reverse Vowels of a String | Python | Easy | String | |
| 347 | Top K Frequent Elements | Python | Medium | Hash Table | |
| 365 | Water and Jug Problem | Python | Medium | Math;DFS | |
| 374 | Guess Number Higher or Lower | Python | Easy | Binary Search | |
| 376 | Wiggle Subsequence | Python | Medium | Dynamic Programming | |
| 381 | Insert Delete Getrandom o1 Duplicates Allowed | Python | Hard | Design | |
| 383 | Ransom Note | Python | Easy | String | |
| 384 | Top K Frequent Elements | Python | Medium | Designing | |
| 387 | First Unique Character in a String | Python | Easy | Hash Table | |
| 389 | Find the Difference | Python | Easy | Hash Table | |
| 392 | Is Subsequence | Python | Easy | Dual Pointer | |
| 395 | Longest Substring with At Least K Repeating Characters | Python | Medium | Divide and Conquer | |
| 402 | Remove k Digits | Python | Medium | Array | |
| 409 | Longest Palindrome | Python | Easy | Hash Table | |
| 413 | Arithmetic Slices | Python | Medium | Dynamic Programming | |
| 416 | Partition Equal Subset Sum | Python | Medium | Dynamic Programming; 0-1 Backpack Problem | |
| 417 | Pacific Atlantic Water Flow | Python | Medium | DFS; BFS | |
| 429 | N-ary Tree Level Order Traversal | Python | Easy | Tree | |
| 430 | Flatten a Multilevel Doubly Linked List | Python | Medium | DFS; Linked List | |
| 434 | Number of Segments in a String | Python | Easy | String | |
| 435 | Non-overlapping Intervals | Python | Medium | Greedy Algorithm | |
| 437 | Path Sum III | Python | Easy | Tree | |
| 441 | Arranging Coins | Python | Easy | Math; Binary Search | |
| 443 | String Compression | Python | Medium | String; Dual Pointer | |
| 447 | Number of Boomerangs | Python | Easy | Hash Table | |
| 448 | Find All Numbers Disappeared in an Array | Python | Easy | Array | |
| 451 | Sort Characters By Frequency | Python | Medium | Hash Table; Stack | |
| 452 | Minimum Number of Arrows to Burst Balloons | Python | Medium | Greedy Algorithm | |
| 455 | Assign Cookies | Python | Easy | Greedy Algorithm | |
| 459 | Repeated Substring Pattern | Python | Easy | String | |
| 461 | Hamming Distance | Python | Easy | Bit | |
| 482 | License Key Formatting | Python | Easy | String | |
| 485 | Max Consecutive Ones | Python | Easy | Array | |
| 491 | Increasing Subsequences | Python | Medium | DFS | |
| 492 | Construct the Rectangle | Python | Easy | ||
| 494 | Target Sum | Python | Medium | DFS; Dynamic Programming | |
| 495 | Teemo Attacking | Python | Medium | Array | |
| 496 | Next Greater Element I | Python | Easy | Stack | |
| 500 | Keyboard Row | Python | Easy | ||
| 501 | Find Mode in Binary Search Tree | Python | Easy | Tree | |
| 513 | Find Bottom Left Tree Value | Python | Medium | BFS | |
| 530 | Minimum Absolute Difference in BST | Python | Medium | BFS | |
| 537 | Complex Number Multiplication | Python | Medium | String | |
| 543 | Diameter of Binary Tree | Python | Easy | DFS | |
| 547 | Number of Provinces | Python | Medium | DFS | |
| 557 | Reverse Words in a String III | Python | Easy | String | |
| 560 | Subarray Sum Equals K | Python | Medium | Presum; Hash Table | |
| 563 | Binary Tree Tilt | Python | Easy | Tree | |
| 566 | Reshape the Matrix | Python | Easy | Array | |
| 576 | Out of Boundary Paths | Python | Medium | Dynamic Programming | |
| 581 | Shortest Unsorted Continuous Subarray | Python | Medium | Dual Pointer | |
| 589 | N-ary Tree Preorder Traversal | Python | Easy | Tree | |
| 590 | N-ary Tree Postorder Traversal | Python | Easy | Tree | |
| 598 | Range Addition ii | Python | Easy | Array; Maths | |
| 605 | Can Place Flowers | Python | Easy | Array | |
| 617 | Merge Two Binary Trees | Python | Easy | DFS | |
| 621 | Task Scheduler | Python | Medium | Array | |
| 637 | Average of Levels in Binary Tree | Python | Easy | Tree | |
| 643 | Maximum Average Subarray I | Python | Easy | Array | |
| 647 | Palindromic Substrings | Python | Medium | Dual Pointer | |
| 649 | Dota2 Senate | Python | Medium | Queue | |
| 657 | Robot Return to Origin | Python | Easy | String | |
| 670 | Maximum Swap | Python | Medium | Array | |
| 697 | Degree of an Array | Python | Easy | Array | |
| 700 | Search in a Binary Search Tree | Python | Easy | BST | |
| 709 | To Lower Case | Python | Easy | String | |
| 713 | Subarray Product Less Than K | Python | Medium | Array; Dual Pointers | |
| 724 | Find Pivot Index | Python | Easy | Array; Prefix Sum | |
| 739 | Daily Temperatures | Python | Medium | Array; Stack | |
| 746 | Min Cost Climbing Stairs | Python | Easy | Dydanmic Programming | |
| 783 | Minimum Distance Between BST Nodes | Python | Easy | BST | |
| 830 | Positions of Large Groups | Python | Easy | Array | |
| 841 | Keys and Rooms | Python | Medium | DFS | |
| 851 | Loud and Rich | Python | Medium | DFS | |
| 867 | Transpose Matrix | Python | Easy | Array | |
| 872 | Leaf Similar Trees | Python | Easy | Binary Tree | |
| 890 | Find and Replace Pattern | Python | Medium | Hash Table | |
| 918 | Maximum Sum Circular Subarray | Python | Medium | Kadane | |
| 933 | Number of Recent Calls | Python | Easy | Queue | |
| 993 | Cousins in Binary Tree | Python | Easy | Tree; DFS | |
| 1004 | Max Consecutive Ones III | Python | Medium | Array | |
| 1018 | Binary Prefix Divisible by 5 | Python | Easy | Array | |
| 1024 | Video Stitching | Python | Medium | Dydanmic Programming | |
| 1047 | Remove all Adjacent Duplicates in String | Python | Easy | Stack | |
| 1078 | Occurrences After Bigram | Python | Easy | String | |
| 1137 | N th Tribonacci Number | Python | Easy | Maths | |
| 1143 | Longest Common Subsequence | Python | Medium | Dydanmic Programming | |
| 1207 | Unique Number of Occurrences | Python | Easy | Hash Table | |
| 1332 | Remove Palindromic Subsequences | Python | Easy | String | |
| 1372 | Longest Zigzag Path in a Binary Tree | Python | Medium | Binary Tree; DFS | |
| 1431 | Kids With the Greatest Number of Candies | Python | Medium | Array | |
| 1448 | Count Good Nodes in Binary Tree | Python | Medium | Binary Tree | |
| 1456 | Maximum Number of Vowels in a Substring of Given Length | Python | Medium | Array | |
| 1493 | Longest Subarray of 1s After Deleting One Element | Python | Medium | Array | |
| 1679 | Max Number of K Sum Pairs | Python | Medium | Dual Pointer | |
| 1701 | Greatest Common Divisor of Strings | Python | Easy | String | |
| 1732 | Find the Highest Altitude | Python | Easy | Array; Prefix Sum | |
| 1736 | Latest Time By Replacing Hidden Digits | Python | Easy | String | |
| 1748 | Sum of Unique Elements | Python | Easy | Hash Table | |
| 1768 | Merge Strings Alternately | Python | Easy | String | |
| 1791 | Find Center of Star Graph | Python | Easy | Hash Table | |
| 2095 | Delete the Middle Node of A Linked List | Python | Medium | Linked List | |
| 2215 | Find the Difference of Two Arrays | Python | Easy | Hash Table | |
| 2300 | Successful Pairs of Spells and Potions | Python | Medium | Binary Search | |
| 2390 | Removing Stars From a String | Python | Medium | Stack | |
| 2520 | Count the Digits That Divide a Number | Python | Easy | Maths | |
| 2558 | Take Gifts From the Richest Pile | Python | Easy | Heap | |
| LCP3 | programmable Robot | Python | Medium | ||
| MS10.02 | Group Anagrams Lcci | Python | Medium | Hash Table | |
| MS17.14 | Group Anagrams Lcci | Python | Medium | Heap | |
| JZ29 | Sorted Circular List | Python | Medium | List | |
| JZ38 | Permutation | Python | Medium | Backtrack | |
| JZ69 | B1IidL | Python | Easy | Binary Search | |
| JZ10-1 | Fibonacci | Python | Easy | Dydanmic Programming |