Awesome Open Source
Awesome Open Source
Sponsorship

算法/Algorithm

我个人的力扣答案, #公众号:GeekBro
这是一个持续更新的开源项目

My personal leetcode answers
This is a continually updated open source project

文章/Articles

软件/Softwares

书籍/Books

Leetcode

Math

Problem Solution Time Space Difficulty Note
263.ugly-number cpp, python O(1) O(1) Easy O(T) = O(LogN), N <= 2^31, O(T) = 32
Problem Solution Time Space Difficulty Note Grade
002.add-two-numbers cpp, python O(N) O(1) Medium/S--
007.reverse-integer cpp, python O(L) O(1) Easy/S--
008.string-to-integer-atoi cpp, python O(N) O(1) Medium/S-- Overflow Check Awesome
009.palindrome-number python O(N) O(1) Easy
012.integer-to-roman cpp, python O(N) Medium N = length of results
013.roman-to-integer cpp, python O(N) Easy
043.multiply-strings cpp, python O(M*N) O(M+N) Medium/S++
048.rotate-image cpp, python O(MN) O(1) Medium/S++
067.add-binary cpp, python O(N) O(1) Easy
202.happy-number cpp, python O(N) Easy
273.integer-to-english-words python O(N) O(N) Hard
311.sparse-matrix-multiplication cpp, python O(N^3) O(N^2) Medium/S--
326.power-of-three python O(1) O(1) Easy/S++
342.power-of-four python O(1) O(1) Easy/S++
415.add-strings cpp, python O(N) O(1) Easy
829.consecutive-numbers-sum python O(sqrt(N)) O(1) Hard
836.rectangle-overlap cpp, python O(1) O(1) Easy

Bit

Problem Solution Time Space Difficulty Note Grade
136.single-number cpp, python O(N) O(1) Easy xor Perfect
231.power-of-two python O(1) O(1) Easy
318.maximum-product-of-word-lengths cpp, python O(N^2) O(N) Medium/S++ mask Great
393.utf-8-validation cpp, python O(N) O(1) Medium/S-- Perfect
751.ip-to-cidr python O(N) O(1) Easy/SSS

Design

Problem Solution Time Space Difficulty Note Grade
535.encode-and-decode-tinyurl python O(1) O(N) Medium

Array and String

Problem Solution Time Space Difficulty Note
038.count-and-say python N/A O(1) Easy
169.majority-element cpp, python O(N) O(1) Easy Boyer–Moore majority vote algorithm
229.majority-element-ii cpp, python O(N) O(1) Medium Boyer–Moore majority vote algorithm
Problem Solution Time Space Difficulty Note Grade
014.longest-common-prefix cpp, python O(S) O(1) Easy/S-- Trie Perfect
031.next-permutation cpp, python O(N) O(1) Medium Array Great
041.first-missing-positive python O(N) O(1) Hard
042.trapping-rain-water cpp, python O(N) O(N) Hard Scan Twice Perfect
054.spiral-matrix cpp python O(N) O(1) Medium
056.merge-intervals cpp, python O(N * logN) O(1) Medium Sort N = number of intervals
057.insert-interval cpp, python O(N) O(1) Hard Sort N = number of intervals
066.plus-one cpp, python O(N) O(1) Easy
068.text-justification python O(N) O(N) Hard
118.pascals-triangle cpp, python O(N^2) O(1) Easy Perfect
119.pascals-triangle-ii cpp, python O(N^2) O(1) Easy Perfect
157.read-n-characters-given-read4 cpp, python O(N) O(1) Easy String
161.one-edit-distance cpp, python O(N) O(1) Medium String Perfect
163.missing-ranges cpp, python O(N) O(1) Medium Array Mind int overflow
215.kth-largest-element-in-an-array cpp, python O(N) O(1) Medium/S-- quick-select best = O(N), worst = O(N^2)
228.summary-ranges python O(N) O(1) Medium
240.search-a-2d-matrix-ii cpp, python O(M + N) O(1) Medium
251.flatten-2d-vector python - O(N) Medium
271.encode-and-decode-strings cpp, python O(N) O(1) Easy String N = count of chars
277.find-the-celebrity cpp, python O(N) O(1) Medium
280.wiggle-sort python O(N) O(1) Medium
289.game-of-life python O(MN) O(1) Medium
$324.wiggle-sort-ii python O(NLogN) O(N) Medium Follow up
370.range-addition cpp, python O(N + K) O(1) Medium Array Perfect
388.longest-absolute-file-path cpp, python O(N) O(N) Medium String
408.valid-word-abbreviation cpp, python O(N) O(1) Easy
448.find-all-numbers-disappeared-in-an-array python O(N) O(1) Easy/SSS
463.island-perimeter python O(N) O(1) Easy/S++
527.word-abbreviation cpp, python O(N * L) O(N) Hard L = avg word length
560.subarray-sum-equals-k cpp, python O(N) O(N) Medium Great
657.robot-return-to-origin python O(N) O(1) Easy
674.longest-continuous-increasing-subsequence cpp, python O(N) O(1) Easy Perfect
755.pour-water python O(N^2) O(1) Medium/S--
796.rotate-string cpp, python O(N) O(1) Easy string
929.unique-email-addresses python O(N) O(N) Easy
Problem Solution Time Difficulty Tag Note
350.intersection-of-two-arrays-ii python O(N * logN) Easy
485.max-consecutive-ones cpp O(N) Easy
498.diagonal-traverse cpp O(MN) Medium
561.array-partition-i cpp O(N * logN) Easy
724.find-pivot-index cpp O(N) Easy
747.largest-number-at-least-twice-of-others cpp O(N) Easy
832.flipping-an-image python O(N) O(N) Easy
859.buddy-strings cpp O(N) Easy string

Two Pointers

Problem Solution Time Space Difficulty Note Grade
003.longest-substring-without-repeating-characters cpp, python O(N) O(N) Medium
011.container-with-most-water python O(N) O(1) Medium
015.3sum cpp, python O(N^2) O(1) Medium/S++ Awesome
016.3sum-closest cpp, python O(N^2) O(1) Medium Cool
018.4sum cpp, python O(N^3) O(1) Medium Awesome
019.remove-nth-node-from-end-of-list cpp, python O(N) O(1) Medium Perfect
026.remove-duplicates-from-sorted-array cpp, python O(N) O(1) Easy Perfect
027.remove-element cpp, python O(N) O(1) Easy
028.implement-strstr cpp, python O(M + N) O(1) Easy Pattern Searching KMP
042.trapping-rain-water cpp, python O(N) O(1) Hard Two Pointers
075.sort-colors cpp python O(N) O(1) Medium counting-sort
076.minimum-window-substring cpp, python O(N) O(N) Hard
088.merge-sorted-array cpp, python O(N + M) O(1) Easy Perfect
125.valid-palindrome cpp, python O(N) O(1) Easy Perfect
159.longest-substring-with-at-most-two-distinct-characters cpp, python O(N) O(N) Hard
167.two-sum-ii-input-array-is-sorted cpp, python O(N) O(1) Easy Perfect
209.minimum-size-subarray-sum cpp, python O(N) O(1) Medium
234.palindrome-linked-list cpp, python O(N) O(1) Easy maybe Harder
283.move-zeroes cpp, python O(N) O(1) Easy Perfect
340.longest-substring-with-at-most-k-distinct-characters cpp, python O(N) O(N) Hard Cool
344.reverse-string cpp, python O(N) O(1) Easy
345.reverse-vowels-of-a-string cpp, python O(N) O(1) Easy
350.intersection-of-two-arrays-ii cpp, python O(K * logK), k = max(M, N) O(1) Easy hash, binary-search
532.k-diff-pairs-in-an-array cpp, python O(N * logN) O(1) Easy Hash
844.backspace-string-compare cpp, python O(N) O(1) Easy stack

Linked List

There is actually no algorithm in linked list question, but is really tricky to get one right

Problem Solution Time Space Difficulty Grade Note
021.merge-two-sorted-lists cpp, python O(N) O(1) Easy Perfect
024.swap-nodes-in-pairs cpp, python O(N) O(1) Medium Great
025.reverse-nodes-in-k-group cpp, python O(N) O(1) Hard/S-- Perfect
086.partition-list cpp, python O(N) O(1) Medium Perfect
092.reverse-linked-list-ii cpp, python O(N) O(1) Medium Perfect
141.linked-list-cycle cpp, python O(N) O(1) Easy perfect
142.linked-list-cycle-ii cpp, python O(N) O(1) Medium/S++ Perfect
160.intersection-of-two-linked-lists cpp, python O(N + M) Easy Perfect two-pointers
206.reverse-linked-list cpp, python O(N) O(1) Easy/S++ Perfect
Problem Solution Time Difficulty Tag Note
61.rotate-list python O(N) Medium
143.reorder-list python O(N) Medium
138.copy-list-with-random-pointer python O(N) Medium
148.sort-list python O(N * logN) Medium
203.remove-linked-list-elements python O(N) Easy
237.delete-node-in-a-linked-list python O(1) Easy
328.odd-even-linked-list python O(N) Medium

Binary Search

Problem Solution Time Space Difficulty Note
004.median-of-two-sorted-arrays cpp, python O(log(N)) O(1) TODO: find kth solution
278.first-bad-version cpp, python O(logN) O(1) Easy 3 template
658.find-k-closest-elements cpp, python Log(N - K) O(1) Medium
704.binary-search cpp, python O(logN) O(1) Easy TODO: missing one template
1150.check-if-a-number-is-majority-element-in-a-sorted-array.cpp cpp, python O(logN) O(1) Easy
Problem Solution Time Space Difficulty Statistic Note
029.divide-two-integers cpp, python O(logN) O(1) Medium/S++ Math
$033.search-in-rotated-sorted-array cpp, python O(logN) O(1) Medium/S++ Perfect
034.find-first-and-last-position-of-element-in-sorted-array cpp, python O(LogN) O(1) Medium Perfect
050.powx-n cpp, python O(logN) O(1) Medium/S++
$069.sqrtx cpp, python O(logN) O(1) Easy Perfect
074.search-a-2d-matrix cpp, python O(logN) O(1) Medium N = row * col
081.search-in-rotated-sorted-array-ii cpp, python O(logN) ~ O(N) O(1) Medium/S++
153.find-minimum-in-rotated-sorted-array cpp, python O(logN) O(1) Medium Perfect
154.find-minimum-in-rotated-sorted-array-ii cpp, python O(logN) ~ O(N) O(1) Hard
162.find-peak-element cpp, python O(logN) O(1) Medium Perfect
270.closest-binary-search-tree-value cpp, python O(LogN) O(1) Easy Perfect
302.smallest-rectangle-enclosing-black-pixels cpp, python O(MLogN + NLogM) O(1) Hard/SSS Perfect
367.valid-perfect-square cpp, python O(LogN) O(1) Easy Perfect
374.guess-number-higher-or-lower cpp, python O(LogN) O(1) Easy Perfect
702.search-in-a-sorted-array-of-unknown-size cpp, python O(LogN) O(1) Medium Perfect
852.peak-index-in-a-mountain-array cpp, python O(logN) O(1) Easy Golden-section search
1150.check-if-a-number-is-majority-element-in-a-sorted-array.cpp cpp, python O(logN) O(1) Easy

Divide and Conquer

Problem Solution Time Space Difficulty Note
098.validate-binary-search-tree cpp, python O(N) O(1) Medium
236.lowest-common-ancestor-of-a-binary-tree cpp, python O(N) O(1) Medium
Problem Solution Time Space Difficulty Note Grade
104.maximum-depth-of-binary-tree cpp, python O(N) O(1) Easy Perfect
110.balanced-binary-tree cpp, python O(N) O(1) Easy Perfect
273.integer-to-english-words python O(N) O(N) Hard
282.expression-add-operators cpp, python O(2 ^ N) O(N) Hard/SSS DFS N = length of input
687.longest-univalue-path cpp, python O(N) O(1) Easy/S++ Perfect

Tree Traversal

Problem Solution Time Space Difficulty Note Grade
94.binary-tree-inorder-traversal cpp, python O(N) O(1) Medium/S++ Perfect
102.binary-tree-level-order-traversal cpp, python O(N) O(H) Medium Perfect
103.binary-tree-zigzag-level-order-traversal cpp, python O(N) O(N) Medium Perfect
107.binary-tree-level-order-traversal-ii cpp, python O(N) O(N) Easy Perfect
114.flatten-binary-tree-to-linked-list cpp, python O(N) O(1) Medium Cool
130.surrounded-regions cpp, python O(MN) O(M & N) Medium BFS
144.binary-tree-preorder-traversal cpp, python O(N) O(1) Medium/S-- Perfect
145.binary-tree-postorder-traversal cpp, python O(N) O(1) Hard/SSS Perfect
156.binary-tree-upside-down cpp, python O(V) O(1) Medium
173.binary-search-tree-iterator cpp, python O(1) O(H) Medium/S-- Perfect
257.binary-tree-paths cpp, python O(N) O(1) Easy Perfect
285.inorder-successor-in-bst cpp, python O(H) O(1) Medium BST H = height of the tree
286.walls-and-gates cpp, python O(MN) O(MN) Medium BFS
297.serialize-and-deserialize-binary-tree cpp, python O(N) O(N) Hard Cool
314.binary-tree-vertical-order-traversal cpp, python O(V) O(V) Medium
366.find-leaves-of-binary-tree cpp, python O(V) O(V) Medium
426.convert-binary-search-tree-to-sorted-doubly-linked-list cpp, python O(N) O(1) Medium Perfect
538.convert-bst-to-greater-tree cpp, python O(V) O(1) Easy

Graph Traversal

Problem Solution Time Space Difficulty Note Grade
127.word-ladder cpp, python O(N^2 * L^2) O(N) Medium/S++ BFS Bad
133.clone-graph cpp, python O(V + E) O(N) Medium Great
200.number-of-islands cpp, python O(MN) O(MN) Medium BFS/DFS union-find
207.course-schedule cpp, python O(V + E) O(V + E) Medium Perfect
210.course-schedule-ii cpp, python O(V + E) O(V) Medium topological-sort Awesome
269.alien-dictionary python O(V + E) O(V + E) Hard
323.number-of-connected-components-in-an-undirected-graph cpp, python O(V+E) O(V+E) Medium union-find Bad
433.minimum-genetic-mutation cpp, python O(V + E) O(N) Medium
444.sequence-reconstruction cpp, python O(V+E) O(V) Medium topological-sort
773.sliding-puzzle python O(V + E) O(N) Hard/SSS
815.bus-routes python O(V + E) O(N) Hard/SSS

Backtracking

Problem Solution Time Space Difficulty Note
037.sudoku-solver python O(2 ^ N) O(N) Medium N = black count
Problem Solution Time Space Difficulty Tag Note
017.letter-combinations-of-a-phone-number cpp, python O(2 ^ N) O(N) Medium
022.generate-parentheses python O(ans) O(N) Medium
039.combination-sum cpp, python O(N^K), k=target/min O(K) Medium DFS Perfect
040.combination-sum-ii cpp, python O(2^K), k=target/min O(K) Medium/S-- DFS Perfect
046.permutations cpp, python O(N * N!) O(N) Medium DFS Perfect
047.permutations-ii cpp, python O(N * N!) O(N) Medium/S++ DFS Perfect
051.n-queens cpp, python O(N^N) O(N) Hard DFS Awesome
052.n-queens-ii cpp, python O(N^N) O(N) Hard DFS Perfect
078.subsets cpp, python O(N * 2^N) O(N) Medium DFS/Iteration/Bit
079.word-search cpp, python O(MN * L^2), L = length of words O(MN) Medium DFS
090.subsets-ii cpp, python O(N * 2^N) O(N) Medium(S++) DFS/Iteration
126.word-ladder-ii cpp, python - O(N) Hard/SSS DFS Pruning Awesome
131.palindrome-partitioning cpp, python O(2^N) O(N) Medium DFS Perfect

Hash Table

Problem Solution Time Space Difficulty Note
036.valid-sudoku cpp, python O(N ^ 2) O(N ^ 2) Medium array-indexes
Problem Solution Time Space Difficulty Grade Note
001.two-sum cpp, python O(N) O(N) Easy Perfect
030.substring-with-concatenation-of-all-words cpp, python O(MN) O(M) Hard/SSS Cool TODO O(N)
49.group-anagrams cpp O(N * k * Logk) Medium
170.two-sum-iii-data-structure-design cpp, python O(N) O(N) Easy Awesome
202.happy-number cpp, python O(N) Easy
217.contains-duplicate cpp O(N) Easy
219.contains-duplicate-ii cpp O(N) Easy
242.valid-anagram cpp, python O(N) O(1) Easy Perfect
249.group-shifted-strings cpp O(N * K) Medium
347.top-k-frequent-elements cpp O(N * LogN) Medium TODO: quick-sort, bucket-sort
350.intersection-of-two-arrays-ii cpp O(MN) Easy
359.logger-rate-limiter cpp O(1) Easy amortized
380.insert-delete-getrandom-o1 cpp O(1) Medium
447.number-of-boomerangs cpp, python O(N^2) O(N) Easy Cool
454.4sum-ii cpp O(N ^ 2) Medium
599.minimum-index-sum-of-two-lists cpp O(M + N) Easy
652.find-duplicate-subtrees cpp O(N) Medium
760.find-anagram-mappings python O(N) O(N) Easy
771.jewels-and-stones cpp O(M + N) Easy
Problem Solution Time Space Difficulty Note Grade
128.longest-consecutive-sequence cpp, python O(N) O(N) Hard/S++ Union-find
205.isomorphic-strings cpp, python O(N) O(N) Easy
246.strobogrammatic-number cpp, python O(N) O(1) Easy
288.unique-word-abbreviation cpp, python O(1) O(N) Medium
349.intersection-of-two-arrays cpp, python O(K * logK), k = max(M, N) O(1) Easy two-pointers, binary-search perfect
387.first-unique-character-in-a-string cpp, python O(N) O(N) Easy
438.find-all-anagrams-in-a-string cpp, python O(N) O(N) Easy

queue

Problem Solution Time Space Difficulty Grade Node
239.sliding-window-maximum cpp, python O(N) O(N) Hard Great
346.moving-average-from-data-stream cpp, python O(1) O(N) Easy Perfect
933.number-of-recent-calls cpp, python O(Inputs) O(1) Easy Perfect Fast I/O for Competitive Programming

Heap

Problem Solution Time Space Difficulty Note Grade
$023.merge-k-sorted-lists cpp, python O(N * LogK) O(K) Hard Perfect
295.find-median-from-data-stream cpp, python O(NLogN) O(N) Medium Cool
378.kth-smallest-element-in-a-sorted-matrix cpp, python O((K + M) * LogM) O(M) Medium TODO: binary-search, O(N) solution
407.trapping-rain-water-ii cpp, python O(M * N * Log(M + N)) O(M + N) Hard/SSS Bad

Stack

Problem Solution Time Space Difficulty Note Grade
020.valid-parentheses cpp, python O(N) O(N) Easy Perfect
084.largest-rectangle-in-histogram cpp, python O(N) O(N) Hard/S++ Perfect
085.maximal-rectangle cpp, python O(MN) O(N) Hard/SSS Perfect
155.min-stack cpp, python O(1) O(N) Easy/S-- Cool
341.flatten-nested-list-iterator python - O(N) Medium/S++
394.decode-string cpp, python O(N) O(N) Medium Perfect
654.maximum-binary-tree cpp, python O(N) O(N) Hard/SSS Perfect
739.daily-temperatures python O(N) O(N) Medium

Sweep Line

Problem Solution Time Space Difficulty Note Grade
$253.meeting-rooms-ii cpp, python O(NlogN) O(N) Medium Perfect

Dynamic Programming

Problem Solution Time Space Difficulty Note Grade
005.longest-palindromic-substring python O(N^2) O(1) Medium
010.regular-expression-matching cpp, python O(MN) O(MN) Hard/S++ Sequence
044.wildcard-matching cpp, python O(MN) O(MN) Hard Sequence
053.maximum-subarray cpp, python O(N) O(1) Easy Perfect
062.unique-paths cpp, python O(MN) O(MN) Medium Coordinates
063.unique-paths-ii cpp, python O(MN) O(MN) Medium Coordinates
064.minimum-path-sum cpp, python O(MN) O(MN) Medium Coordinates
070.climbing-stairs cpp, python O(N) O(1) Easy Coordinates Perfect
072.edit-distance cpp, python O(MN) O(N) Hard/S-- Sequence
087.scramble-string cpp, python O(N^4) O(N^3) Hard/SSS Range
091.decode-ways cpp, python O(N) O(N) Medium/S++ Partition
097.interleaving-string cpp, python O(MN) O(MN) Hard/S-- Sequence
115.distinct-subsequences cpp, python O(MN) O(MN) Hard/S-- Sequence
120.triangle cpp, python O(N^2) O(N) Medium Coordinates Perfect
132.palindrome-partitioning-ii cpp, python O(N^2) O(N^2) Hard Partition
188.best-time-to-buy-and-sell-stock-iv cpp, python O(N*K) O(N * K) Hard/SSS
198.house-robber cpp, python O(N) O(1) Easy Sequence Perfect
121.best-time-to-buy-and-sell-stock cpp, python O(N) O(1) Easy Coordinates
123.best-time-to-buy-and-sell-stock-iii cpp, python O(N) O(N) Hard/SSS
213.house-robber-ii cpp, python O(N) O(1) Medium/S-- Sequence Perfect
221.maximal-square cpp, python O(MN) O(N) Medium/S-- Coordinates Perfect
256.paint-house cpp, python O(N) O(N) Easy/S-- Sequence
265.paint-house-ii cpp, python O(MN) O(MN) Hard Sequence
276.paint-fence cpp, python O(N) O(1) Easy/SSS Perfect
279.perfect-squares cpp, python O(N ^ 1.5) O(N) Medium Partition
300.longest-increasing-subsequence cpp, python O(NlogN) O(N) Medium/SSS Binary-search / DP Perfect
312.burst-balloons cpp, python O(N^3) O(N^2) Hard/S-- Range
322.coin-change cpp, python O(L*N) O(N) Medium N = amount, L = len(coins)
338.counting-bits cpp, python O(N) O(1) Medium/S-- Bit-manipulation
354.russian-doll-envelopes cpp, python O(N*logN) O(N) Hard/S-- Coordinates
$361.bomb-enemy cpp, python O(MN) O(MN) Medium/S++ Coordinates
$368.largest-divisible-subset cpp, python O(N^2) O(N) Medium/S++ Coordinates Awesome
377.combination-sum-iv cpp, python O(M*N) O(N) Medium Backpack
474.ones-and-zeroes cpp, python O(LMN) O(LMN) Medium Sequence
516.longest-palindromic-subsequence cpp, python O(N^2) O(N^2) Medium
787.cheapest-flights-within-k-stops python O(K * E) O(N) Hard/SSS

Red Black Tree

Since python got no built-in AVL data-structure, these questions written in python may perform worse

Problem Solution Time Space Difficulty Note Grade
$683.k-empty-slots cpp, python O(NLogN) O(N) Hard/SSS Min Queue Bad

Greedy

Problem Solution Time Space Difficulty Tag Note
45.jump-game-ii cpp, python O(N) O(1) Hard
055.jump-game cpp, python O(N) O(1) Medium dynamic-programming
122.best-time-to-buy-and-sell-stock-ii cpp, python O(N) O(1) Easy
$406.queue-reconstruction-by-height cpp, python O(N^2) O(1) Medium/S++ Sort Multiple Keys

Union Find

Problem Solution Time Space Difficulty Note Grade
261.graph-valid-tree cpp, python O(E) O(N) Medium BFS/DFS Perfect
305.number-of-islands-ii cpp, python O(N) O(MN) Hard N = len(positions)
721.accounts-merge cpp, python O(MN) O(MN) Medium
924.minimize-malware-spread python O(N^2) O(N) Hard TODO Bad

Trie

Problem Solution Time Space Difficulty Tag Note
208.implement-trie-prefix-tree cpp, python O(L) O(N * L) Medium - L = len(word), N = number of words
211.add-and-search-word-data-structure-design cpp, python add = O(L), find >= O(L) O(N * L) Medium/S-- DFS L = len(word), N = count(words)
212.word-search-ii cpp, python O(M * N * L * L) MAX(O(MN), O(K * L)) Hard DFS K = number of words, L = avg length of words
336.palindrome-pairs python O(N * L^2) O(N) Hard/SSS
425.word-squares cpp, python O(-) O(NL) Hard/SSS DFS Pruning
677.map-sum-pairs cpp, python O(L), O(KL) O(N * L) Medium L = length of input, k = number of items found

Other

Problem Solution Difficulty Tag Note
175.combine-two-tables sql Easy SQL

Lintcode

Below are Lintcode questions that worth trying

Problem Solution Time Space Difficulty Tag Note
039.recover-rotated-sorted-array cpp, python O(N) O(1) Easy/S++ Binary-search, Two-pointers
077.longest-common-subsequence cpp, python O(M*N) O(M*N) Medium dynamic-programming
081.find-median-from-data-stream cpp, python O(N * LogN) O(N) Hard Heap
089.k-sum cpp, python O(NKT) O(NKT) Hard dynamic-programming
091.minimum-adjustment-cost cpp, python O((100^2)N) O(100N) Medium dynamic-programming
092.backpack cpp, python O(M*N) O(M) Medium dynamic-programming
125.backpack-ii cpp, python O(M*N) O(M) Medium/S++ dynamic-programming
139.subarray-sum-closest cpp, python O(NlogN) O(N) Medium Subarray
144.interleaving-positive-and-negative-numbers cpp, python O(N) O(1) Medium two-pointers
183.wood-cut cpp, python O(N * LogN) O(1) Medium/S-- binary-search
382.triangle-count cpp, python O(N^2) O(1) Medium two-pointers
390.find-peak-element-ii cpp, python O(M + N) O(1) Hard/SSS binary-search
391.number-of-airplanes-in-the-sky cpp, python O(NlogN) O(N) Medium sweep-line
394.coins-in-a-line cpp, python O(N) O(N) Medium dynamic-programming
396.coins-in-a-line-iii cpp, python O(N^2) O(N^2) Hard/SSS dynamic-programming
437.copy-books cpp, python O(K * N^2) / O(N * LogA) O(NK) Hard/SSS dynamic-programming / binary-search
440.backpack-iii cpp, python O(MN) O(M) Hard/SSS dynamic-programming
447.search-in-a-big-sorted-array cpp, python O(LogK) O(1) binary-search Medium/S++
465.kth-smallest-sum-in-two-sorted-arrays cpp, python O((K + N) * LogN) O(N) Hard heap N = B.size()
543.kth-largest-in-n-arrays cpp, python O(M * N * LogK) O(K) Easy heap
526.load-balancer cpp, python O(1) O(N) Medium Hash + Array
563.backpack-v cpp, python O(M*N) O(M) Medium dynamic-programming
586.sqrtx-ii cpp, python O(logN) O(N) Medium binary-search
589.connecting-graph cpp, python O(1) O(N) Medium union-find
590.connecting-graph-ii cpp, python O(1) O(N) Medium union-find
591.connecting-graph-iii cpp, python O(1) O(N) Medium union-find
598.zombie-in-matrix cpp, python O(MN) O(MN) Medium graph-traversal
611.knight-shortest-path cpp, python O(MN) O(MN) Medium graph-traversal
618.search-graph-nodes cpp, python O(V + E) O(V) Medium tree-traversal
629.minimum-spanning-tree cpp, python O(N * logN) O(N) Hard union-find Prim, Kruskal
652.factorization cpp, python O(N) O(LogN) Medium/S++ N = input number

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (48,506
cpp (1,176
algorithm (464
data-structures (343
interview (229
leetcode (170
computer-science (146

Find Open Source By Browsing 7,000 Topics Across 59 Categories