/leetcode

Solutions to LeetCode problems by my method; updated daily.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

If you like this project, please leave me a star. ★

Algorithms

# Title Solutions Difficulty Tag
704 binary-search Solution Easy Array, Binary Search
278 first-bad-version Solution Easy Binary Search
35 search-insert-position Solution Easy Array, Binary Search
977 squares-of-a-sorted-array Solution Easy Array, Two Pointers, Sort
189 rotate-array Solution Medium Array, Two Pointers, Math
283 move-zeroes Solution Easy Array, Two Pointers
167 two-sum-ii-input-array-is-sorted Solution Easy Array, Two Pointers, Binary Search
344 reverse-string Solution Easy Recursion, Two Pointers, String
557 reverse-words-in-a-string-iii Solution Easy Two Pointers, String
876 middle-of-the-linked-list Solution Easy LinkedList, Two Pointers
19 remove-nth-node-from-end-of-list Solution Medium LinkedList, Two Pointers
3 longest-substring-without-repeating-characters Solution Medium HashTable, String, Sliding Window
567 permutation-in-string Solution Medium HashTable, Two Pointers, String
733 flood-fill Solution Easy DFS, BFS, Array
695 max-area-of-island Solution Medium DFS, BFS
617 merge-two-binary-trees Solution Easy Tree, DFS, BFS
116 populating-next-right-pointers-in-each-node Solution Medium Tree, DFS, BFS
542 01-matrix Solution Medium BFS, Array, Dynamic Programming
994 rotting-oranges Solution Medium BFS, Array, Matrix
21 merge-two-sorted-lists Solution Easy Recursion, LinkedList
206 reverse-linked-list Solution Easy Recursion, LinkedList
77 combinations Solution Medium Array, Backtracking
46 permutations Solution Medium Array, Backtracking
784 letter-case-permutation Solution Medium Bit Manipulation, String, Backtracking
70 climbing-stairs Solution Easy Memory Search, Math, Dynamic Programming
198 house-robber Solution Medium Array, Dynamic Programming
120 triangle Solution Medium Array, Dynamic Programming
231 power-of-two Solution Easy Bit Manipulation, Recursion, Math
191 number-of-1-bits Solution Easy Bit Manipulation
190 reverse-bits Solution Easy Bit Manipulation, Divide and Conquer
136 single-number Solution Easy Bit Manipulation, Array
34 find-first-and-last-position-of-element-in-sorted-array Solution Medium Array, Binary Search
153 find-minimum-in-rotated-sorted-array Solution Medium Array, Binary Search
33 search-in-rotated-sorted-array Solution Medium Array, Binary Search
82 remove-duplicates-from-sorted-list-ii Solution Medium LinkedList, Two Pointers
844 backspace-string-compare Solution Easy Stack, Two Pointers, String, Simulation
986 interval-list-intersections Solution Medium Array, Two Pointers
438 find-all-anagrams-in-a-string Solution Medium Hash Table, String, Sliding Window
713 subarray-product-less-than-k Solution Medium Array, Sliding Window
200 number-of-islands Solution Medium DFS, BFS
117 populating-next-right-pointers-in-each-node-ii Solution Medium Tree, DFS, BFS
1091 shortest-path-in-binary-matrix Solution Medium BFS, Array, Matrix
78 subsets Solution Medium Bit Manipulation, Array, Backtracking
47 permutations-ii Solution Medium Array, Backtracking
17 letter-combinations-of-a-phone-number Solution Medium Hash Table, String, Backtracking
213 house-robber-ii Solution Medium Array, Dynamic Programming
45 jump-game-ii Solution Medium Greedy, Array, Dynamic Programming
5 longest-palindromic-substring Solution Medium String, Dynamic Programming
91 decode-ways Solution Medium String, Dynamic Programming
300 longest-increasing-subsequence Solution Medium Array, Binary Search, Dynamic Programming
1143 longest-common-subsequence Solution Medium String, Dynamic Programming
322 coin-change Solution Medium BFS, Array, Dynamic Programming
201 bitwise-and-of-numbers-range Solution Medium Bit Manipulation
384 shuffle-an-array Solution Medium Array, Math, Randomized
130 surrounded-regions Solution Medium Array, Math, Randomized
74 search-a-2d-matrix Solution Medium Array, Binary Search, Matrix
162 find-peak-element Solution Medium Array, Binary Search
15 3sum Solution Medium Array, Two Pointers, Sorting
11 container-with-most-water Solution Medium Greedy, Array, Two Pointers
209 minimum-size-subarray-sum Solution Medium Array, Binary Search, Prefix Sum
547 number-of-provinces Solution Medium DFS, BFS
572 subtree-of-another-tree Solution Easy Tree, DFS, Binary Tree
797 all-paths-from-source-to-target Solution Medium DFS, BFS, Graph
90 subsets-ii Solution Medium Bit Manipulation, Array, Backtracking
39 combination-sum Solution Medium Array, Backtracking
22 generate-parentheses Solution Medium String, Dynamic Programming, Backtracking
55 jump-game Solution Medium Greedy, Array, Dynamic Programming
62 unique-paths Solution Medium Math, Dynamic Programming, Combinatorics
40 combination-sum-ii Solution Medium Array, Backtracking
413 arithmetic-slices Solution Medium Array, Backtracking
79 word-search Solution Medium Array, Backtracking, Matrix
139 word-break Solution Medium Trie, Memoization, Array, Hash Table
673 number-of-longest-increasing-subsequence Solution Medium Binary Indexed Tree, Segment Tree, Array
583 delete-operation-for-two-strings Solution Medium String, Dynamic Programming
343 integer-break Solution Medium Math, Dynamic Programming
72 edit-distance Solution Hard String, Dynamic Programming
202 happy-number Solution Easy Hash Table, Math, Two Pointers
149 max-points-on-a-line Solution Hard Geometry, Hash Table, Math
217 contains-duplicate Solution Easy Array, Hash Table, Sorting
1 two-sum Solution Easy Array, Hash Table
350 intersection-of-two-arrays-ii Solution Easy Array, Hash Table, Two Pointers, Binary Search
566 reshape-the-matrix Solution Easy Array, Matrix, Simulation
36 valid-sudoku Solution Medium Array, Hash Table, Matrix
387 first-unique-character-in-a-string Solution Easy Queue, Hash Table, String, Counting
141 linked-list-cycle Solution Easy Hash Table, LinkedList, Two Pointers
83 remove-duplicates-from-sorted-list Solution Easy Hash Table
20 valid-parentheses Solution Easy Stack, String
144 binary-tree-preorder-traversal Solution Easy Stack, Tree, DFS, Binary Tree
104 maximum-depth-of-binary-tree Solution Easy Tree, DFS, BFS
101 symmetric-tree Solution Easy Tree, DFS, BFS
226 invert-binary-tree Solution Easy Tree, DFS, BFS
700 search-in-a-binary-search-tree Solution Easy Tree, Binary Search Tree, Binary Tree
383 ransom-note Solution Easy Hash Table, String, Counting
94 binary-tree-inorder-traversal Solution Easy Stack, Tree, DFS, Binary Tree
53 maximum-subarray Solution Easy Array, Divide And Conquer, Dynamic Programming
88 merge-sorted-array Solution Easy Array, Two Pointers, Sorting
121 best-time-to-buy-and-sell-stock Solution Easy Array, Dynamic Programming
118 pascals-triangle Solution Easy Array, Dynamic Programming
73 set-matrix-zeroes Solution Medium Array, Hash Table, Matrix
242 valid-anagram Solution Easy Hash Table, String, Sorting
203 remove-linked-list-elements Solution Easy Recursion, LinkedList
232 implement-queue-using-stacks Solution Easy Stack, Design, Queue
145 binary-tree-postorder-traversal Solution Easy Stack, Tree, DFS, Binary Tree
102 binary-tree-level-order-traversal Solution Medium Tree, BFS, Binary Tree
112 path-sum Solution Easy Tree, DFS, Binary Tree
701 insert-into-a-binary-search-tree Solution Medium Tree, Binary Search Tree, Binary Tree
653 two-sum-iv-input-is-a-bst Solution Easy Tree, DFS, BFS
235 lowest-common-ancestor-of-a-binary-search-tree Solution Easy Tree, DFS, BFS
98 validate-binary-search-tree Solution Medium Tree, DFS, BFS, Binary Search Tree
169 majority-element Solution Easy Array, Hash Table, Divide and Conquer, Counting
75 sort-colors Solution Medium Array, Two Pointers, Sorting
119 pascals-triangle-ii Solution Easy Array, Dynamic Programming
240 search-a-2d-matrix-ii Solution Medium Array, Binary Search, Divide and Conquer, Matrix
238 product-of-array-except-self Solution Medium Array, Prefix Sum
415 add-strings Solution Easy Math, String, Simulation
290 word-pattern Solution Easy Hash Table, String
43 multiply-strings Solution Medium Math, String, Simulation
706 design-hashmap Solution Easy Design, Array, Hash Table, Linked List
2 add-two-numbers Solution Medium Recursion, Linked List, Math
160 intersection-of-two-linked-lists Solution Easy Hash Table, Linked List, Two Pointers
707 design-linked-list Solution Medium Design, Linked List
143 reorder-list Solution Medium Stack, Recursion, Linked List, Two Pointers
155 min-stack Solution Easy Stack, Design
108 convert-sorted-array-to-binary-search-tree Solution Easy Tree, Binary Search Tree, Array, Divide and Conquer
113 path-sum-ii Solution Medium Tree, DFS, Backtracking, Binary Tree
230 kth-smallest-element-in-a-bst Solution Medium Tree, DFS, Binary Search Tree
236 lowest-common-ancestor-of-a-binary-tree Solution Medium Tree, DFS, Binary Tree
997 find-the-town-judge Solution Easy Graph, Array, Hash Table
215 kth-largest-element-in-an-array Solution Medium Array, Divide and Conquer, Quickselect, Sorting
164 maximum-gap Solution Hard Array, Bucket Sort, Radix Sort, Sorting
56 merge-intervals Solution Medium Array, Bucket Sorting
48 rotate-image Solution Medium Array, Math, Matrix
59 spiral-matrix-ii Solution Medium Array, Math, Matrix
435 non-overlapping-intervals Solution Medium Greedy, Array, Dynamic Programming, Sorting
334 increasing-triplet-subsequence Solution Medium Greedy, Array
409 longest-palindrome Solution Easy Greedy, Hash Table, String
763 partition-labels Solution Medium Greedy, Hash Table, Two Pointers, String
49 group-anagrams Solution Medium Hash Table, String, Sorting
560 subarray-sum-equals-k Solution Medium Array, Hash Table, Prefix Sum
187 repeated-dna-sequences Solution Medium Bit Manipulation, Hash Table, String
142 linked-list-cycle-ii Solution Medium Hash Table, Linked List, Two Pointers
1249 minimum-remove-to-make-valid-parentheses Solution Medium Stack, String
24 swap-nodes-in-pairs Solution Medium Recursion, Linked List
1823 find-the-winner-of-the-circular-game Solution Medium Recursion, Array, Math, Simulation
105 construct-binary-tree-from-preorder-and-inorder-traversal Solution Medium Tree, Array, Hash Table, Divide and Conquer
199 binary-tree-right-side-view Solution Medium Tree, DFS, BFS
25 reverse-nodes-in-k-group Solution Hard Recursion, Linked List
173 binary-search-tree-iterator Solution Medium Stack, Tree, Design, Binary Search Tree
297 serialize-and-deserialize-binary-tree Solution Hard Tree, DFS, BFS
103 binary-tree-zigzag-level-order-traversal Solution Medium Tree, BFS, Binary Tree
1557 minimum-number-of-vertices-to-reach-all-nodes Solution Medium Graph
451 sort-characters-by-frequency Solution Medium Hash Table, String, Bucket Sort, Counting
973 k-closest-points-to-origin Solution Medium Hash Table, String, Bucket Sort, Counting
347 top-k-frequent-elements Solution Medium Array, Hash Table, Divide and Conquer, Bucket Sort
841 keys-and-rooms Solution Medium DFS, BFS, Graph
509 fibonacci-number Solution Easy Recursion, Memoization, Math
746 min-cost-climbing-stairs Solution Easy Array, Dynamic Programming
918 maximum-sum-circular-subarray Solution Medium Queue, Array, Divide and Conquer, Dynamic Programming
152 maximum-product-subarray Solution Medium Array, Dynamic Programming
1014 best-sightseeing-pair Solution Medium Array, Dynamic Programming
309 best-time-to-buy-and-sell-stock-with-cooldown Solution Medium Array, Dynamic Programming
450 delete-node-in-a-bst Solution Medium Tree, Binary Search Tree, Binary Tree
264 ugly-number-ii Solution Medium Hash Table, Math, Dynamic Programming
931 minimum-falling-path-sum Solution Medium Array, Dynamic Programming, Matrix
64 minimum-path-sum Solution Medium Array, Dynamic Programming, Matrix
1314 matrix-block-sum Solution Medium Array, Matrix, Prefix Sum
392 is-subsequence Solution Easy Two Pointers, String, Dynamic Programming
42 trapping-rain-water Solution Hard Stack, Array, Two Pointers, Dynamic Programming
377 combination-sum-iv Solution Medium Array, Dynamic Programming
1137 n-th-tribonacci-number Solution Easy Memoization, Math, Dynamic Programming
740 delete-and-earn Solution Medium Array, Hash Table, Dynamic Programming
1567 maximum-length-of-subarray-with-positive-product Solution Medium Greedy, Array, Dynamic Programming
122 best-time-to-buy-and-sell-stock-ii Solution Medium Greedy, Array, Dynamic Programming
714 best-time-to-buy-and-sell-stock-with-transaction-fee Solution Medium Greedy, Array, Dynamic Programming
96 unique-binary-search-trees Solution Medium Tree, Binary Search Tree, Math, Dynamic Programming
304 range-sum-query-2d-immutable Solution Medium Design, Array, Matrix, Prefix Sum
63 unique-paths-ii Solution Medium Array, Dynamic Programming, Matrix
221 maximal-square Solution Medium Array, Dynamic Programming, Matrix
516 longest-palindromic-subsequence Solution Medium String, Dynamic Programming
518 coin-change-2 Solution Medium Array, Dynamic Programming
9 palindrome-number Python,Go Easy Math
13 roman-to-integer Python,Go Easy Hash Table, Math, String
14 longest-common-prefix Python,Go Easy String
26 remove-duplicates-from-sorted-array Python,Go Easy Array, Two Pointers
27 remove-element Python,Go Easy Array, Two Pointers
28 implement-strstr Python,Go Easy Two Pointers, String, String Matching
58 length-of-last-word Python,Go Easy String
66 plus-one Python,Go Easy Array, Math
67 add-binary Python,Go Easy Bit Manipulation, Math, String, Simulation
69 sqrtx Python,Go Easy Math, Binary Search
100 same-tree Python,Go Easy Tree, DFS, BFS, Binary Tree
110 balanced-binary-tree Python,Go Easy Tree, DFS, Binary Tree
111 minimum-depth-of-binary-tree Python,Go Easy Tree, DFS, BFS, Binary Tree
125 valid-palindrome Python,Go Easy Two Pointers, String
168 excel-sheet-column-title Python,Go Easy Math, String
171 excel-sheet-column-number Python,Go Easy Math, String
175 combine-two-tables SQL Easy Database
205 isomorphic-strings Python,Go Easy Hash Table, String
219 contains-duplicate-ii Python,Go Easy Array, Hash Table, Sliding Window
225 implement-stack-using-queues Python,Go Easy Stack, Design, Queue
228 summary-ranges Python,Go Easy Array
234 palindrome-linked-list Python,Go Easy Stack, Recursion, Linked List, Two Pointers
237 delete-node-in-a-linked-list Python,Go Easy Linked List
257 binary-tree-paths Python,Go Easy Tree, DFS, String, Backtracking, Binary Tree
258 add-digits Python,Go Easy Match, Number Theory, Simulation
263 ugly-number Python,Go Easy Math
268 missing-number Python,Go Easy Bit Manipulation, Array, Hash Table, Math, Sorting
292 nim-game Python,Go Easy Brainteaser, Math, Game Theory
303 range-sum-query-immutable Python,Go Easy Design, Array, Prefix Sum
326 power-of-three Python,Go Easy Recursion, Math
338 counting-bits Python,Go Easy Bit Manipulation, Dynamic Programming
342 power-of-four Python,Go Easy Bit Manipulation, Recursion, Math
345 reverse-vowels-of-a-string Python,Go Easy Two Pointers, String
349 intersection-of-two-arrays Python,Go Easy Array, Hash Table, Two Pointers, Binary Search, Sorting
367 valid-perfect-square Python,Go Easy Math, Binary Search
374 guess-number-higher-or-lower Python,Go Easy Binary Search, interactive
389 find-the-difference Python,Go Easy Bit Manipulation, Hash Table, String, Sorting
401 binary-watch Python,Go Easy Bit Manipulation, Backtracking
404 sum-of-left-leaves Python,Go Easy Tree, DFS, BFS, Binary Tree
405 convert-a-number-to-hexadecimal Python,Go Easy Bit Manipulation, Math
412 fizz-buzz Python, Go Easy Math, String, Simulation
414 third-maximum-number Python,Go Easy Array, Sorting
434 number-of-segments-in-a-string Python,Go Easy String
441 arranging-coins Python, Go Easy Math, Binary Search
448 find-all-numbers-disappeared-in-an-array Python,Go Easy Array, Hash Table
453 minimum-moves-to-equal-array-elements Python,Go Easy Array, Math
455 assign-cookies Python,Go Easy Greedy, Array, Sorting
459 repeated-substring-pattern Python,Go Easy String, String Matching
461 hamming-distance Python,Go Easy Bit Manipulation
463 island-perimeter Python,Go Easy DFS, BFS, Array, Matrix
476 number-complement Python,Go Easy Bit Manipulation
482 license-key-formatting Python,Go Easy String
485 max-consecutive-ones Python,Go Easy Array
496 next-greater-element-i Python,Go Easy Stack, Array, Hash Table, Monotonic Stack
492 construct-the-rectangle Python,Go Easy Math
495 teemo-attacking Python,Go Easy Array, Simulation
500 keyboard-row Go Easy Array, Hash Table, String
501 find-mode-in-binary-search-tree Python,Go Easy Tree, DFS, Binary Search Tree, Binary Tree

Thanks

PyCharm