[LintCode]——目录

2017-01-07 19:01:47来源:cnblogs.com作者:eudiwffe人点击

第七城市

Yet Another Source Code for LintCode

Current Status : 232AC / 289ALL in Language C++, Up to date (2016-02-10)
For more problems and solutions, you can see my LintCode repository.
I'll keep updating for full summary and better solutions. See cnblogs to get details or click problem's Note directly. Tip means has been added tips and sketch (* means has note at cnblogs).
This context template fork from kamyu104 , thanks them very much!

Algorithms

  • Array
  • Backtracking
  • Binary Search
  • Binary Search Trees
  • Bit Manipulation
  • Breadth-First Search
  • Data Structure
  • Depth-First Search
  • Dynamic Programming
  • Greedy
  • Hash Tables
  • Heap
  • Linked List
  • Math
  • OO Design
  • Queue
  • Recursion
  • Sort
  • Stack
  • String
  • System Design
  • Tree

Array

PID#TitleSourceTimeSpaceDifficultyTagNote
6Merge Sorted ArrayC++O(m+n)O(1)EasyLeetCodeTip
8Rotate StringC++O(n)O(1)EasyLeetCodeTip
9Fizz BuzzC++O(n)O(1)EasyTip
30Insert IntervalC++O(n)O(1)EasyLeetCode, EPITip
31Partition ArrayC++O(n)O(1)MediumTip Two Pointers
32Minimum Window SubstringC++O(n)O(1)MediumLeetCodetodo
38Search a 2D Matrix IIC++O(m+n)O(1)MediumEPITip
39Recover Rotated Sorted ArrayC++O(n)O(1)Easy
46Majority NumberC++O(n)O(1)EasyLeetCodeTip
47Majority Number IIC++O(n)O(1)MediumEPI
48Majority Number IIIC++O(n)O(k)MediumEPI
49Sort Letters by CaseC++O(n)O(1)MediumTwo Pointers
50Product of Array Exclude ItselfC++O(n)O(1)Easy
51Previous PermutationC++O(n)O(1)Medium
52Next PermutationC++O(n)O(1)MediumLeetCode
573 SumC++O(n^2 )O(1)MediumLeetCodeTwo Pointers, Sort
584 SumC++O(n^3 )O(1)MediumLeetCodetodo
593 Sum ClosestC++O(n^2 )O(1)MediumLeetCodeTwo Pointers, Sort
64Merge Sorted Array IIC++O(m+n)O(1)EasyLeetCodetodo
100Remove Duplicates from Sorted ArrayC++O(n)O(1)EasyLeetCodeTwo Pointers
101Remove Duplicates from Sorted Array IIC++O(n)O(1)EasyLeetCodeTwo Pointers
133Longest WordsC++O(n)O(n)Easy
144Interleaving Positive and Negative NumbersC++O(n)O(1)MediumTwo Pointers
161Rotate ImageC++O(n^2 )O(1)MediumLeetCode
162Set Matrix ZeroesC++_O(m*n)_O(1)MediumLeetCode
172Remove ElementC++O(n)O(1)EasyLeetCodeTwo Pointers
185Matrix Zigzag TraversalC++_O(m*n)_O(1)Easytodo
189First Missing PositiveC++O(n)O(1)EasyLeetCode, EPIHash
190Next Permutation IIC++O(n)O(1)MediumLeetCode
200Longest Palindromic SubstringC++O(n)O(n)MediumLeetCodeManacher's Algorithm
363Trapping Rain WaterC++O(n)O(1)MediumLeetCodeTwo Pointers, Tricky
373Partition Array by Odd and EvenC++O(n)O(1)EasyTwo Pointers
374Spiral MatrixC++_O(m*n)_O(1)MediumLeetCode
381Spiral Matrix IIC++O(n^2 )O(1)MediumLeetCodetodo
382Triangle CountC++O(n^2 )O(1)Mediumtodo
383Container With Most WaterC++O(n)O(1)MediumLeetCode, EPITwo Pointers
388Permutation SequenceC++O(n^2 )O(n)MediumLeetCode
389Valid SudokuC++O(9^2 )O(9)EasyLeetCode
404Subarray Sum IIC++O(nlogn)O(n)Hardtodo
405Submatrix SumC++_O(m*n^2 )_O(m)Hardtodo
406Minimum Size Subarray SumC++O(n)O(1)MediumLeetCodeTwo Pointers, Binary Search
539Move ZeroesC++O(n)O(1)EasyLeetCodeTwo Pointers

Backtracking

PID#TitleSourceTimeSpaceDifficultyTagNote
15PermutationsC++_O(n*n!)_O(n)MediumLeetCode, EPI
16Permutations IIC++_O(n*n!)_O(n)MediumLeetCode, EPI
17SubsetsC++_O(n*2^n )_O(1)MediumLeetCode
18Subsets IIC++_O(n*2^n )_O(1)MediumLeetCode
33N-QueensC++_O(n*n!)_O(n)MediumLeetCode, EPI
34N-Queens IIC++_O(n*n!)_O(n)MediumLeetCode, EPI
123Word SearchC++O(mnl)O(l)MediumLeetCodetodo
132Word Search IIC++O(mnl)O(l)HardTrie, DFS
135Combination SumC++_O(k*n^k )_O(k)MediumLeetCodeDFS
136Palindrome PartitioningC++O(2^n )O(n)EasyLeetCode, EPI
152CombinationsC++_O(k*n^k )_O(k)MediumLeetCode, EPI
153Combination Sum IIC++_O(k*C(n,k))_O(k)MediumLeetCodeDFS
425Letter Combinations of a Phone NumberC++_O(n*4^n )_O(n)MediumLeetCode
426Restore IP AddressesC++O(1)O(1)MediumLeetCode
427Generate ParenthesesC++O(4^n / n^(3/2) )O(n)MediumLeetCodetodo
PID#TitleSourceTimeSpaceDifficultyTagNote
14First Position of TargetC++O(logn)O(1)Easy
28Search a 2D MatrixC++O(logm + logn)O(1)EasyLeetCode
60Search Insert PositionC++O(logn)O(1)EasyLeetCode
61Search for a RangeC++O(logn)O(1)MediumLeetCode
62Search in Rotated Sorted ArrayC++O(logn)O(1)MediumLeetCode
63Search in Rotated Sorted Array IIC++O(logn)O(1)MediumLeetCode
65Median of two Sorted ArraysC++O(log(min(m,n)))O(1)HardLeetCode, EPItodo
74First Bad VersionC++O(logn)O(1)Medium
75Find Peak ElementC++O(logn)O(1)MediumLeetCode
76Longest Increasing SubsequenceC++O(nlogn)O(n)MediumCTCI
141Sqrt(x)C++O(logn)O(1)EasyLeetCode
159Find Minimum in Rotated Sorted ArrayC++O(logn)O(1)MediumLeetCode
160Find Minimum in Rotated Sorted Array IIC++O(logn)O(1)MediumLeetCode
183Wood CutC++O(nlogL)O(1)Medium
390Find Peak Element IIC++ JavaO(m+n)O(1)Hardtodo
437Copy BooksC++O(nlogp)O(1)HardUVa 714todo

Binary Search Trees

PID#TitleSourceTimeSpaceDifficultyTagNote
11Search Range in Binary Search TreeC++O(n)O(h)MediumEPI
86Binary Search Tree IteratorC++O(1)O(h)HardLeetCode
87Remove Node in Binary Search TreeC++O(h)O(h)Hardtodo
249Count of Smaller Number before itselfC++O(nlogn)O(n)HardBST, BIT, Divide and Conquer, Merge Sort
360Sliding Window MedianC++O(nlogw)O(w)Hardtodo
391Number of Airplanes in the SkyC++O(nlogn)O(n)EasyBST, Heap
401Kth Smallest Number in Sorted MatrixC++O(klog(min(m,n,k)))O(min(m,n,k))MediumBST, Heap

Bit Manipulation

PID#TitleSourceTimeSpaceDifficultyTagNote
1A + B ProblemC++O(1)O(1)Medium
82Single NumberC++O(n)O(1)EasyLeetCode
83Single Number IIC++O(n)O(1)EasyLeetCode
84Single Number IIIC++O(n)O(1)MediumCTCI
142O(1) Check Power of 2C++O(1)O(1)Easy
179Update BitsC++O(1)O(1)MediumCTCI
181Flip BitsC++O(1)O(1)EasyCTCI
196Find the Missing NumberC++O(n)O(1)Medium
365Count 1 in BinaryC++O(1)O(1)EasyCTCI
PID#TitleSourceTimeSpaceDifficultyTagNote
69Binary Tree Level Order TraversalC++O(n)O(n)MediumLeetCodeBFS
70Binary Tree Level Order Traversal IIC++O(n)O(n)MediumLeetCodeBFS
71Binary Tree Zigzag Level Order TraversalC++O(n)O(n)MediumLeetCodeBFS
120Word LadderC++_O(n*d)_O(d)MediumLeetCodeBFS
121Word Ladder IIC++_O(n*d)_O(d)HardLeetCodetodo
127Topological SortingC++O(V+E)O(E)Mediumtodo
137Clone GraphC++O(V+E)O(V)MediumBFS
176Route Between Two Nodes in GraphC++O(n)O(n)MediumDFS, BFS
178Graph Valid TreeC++O(V+E)O(V+E)MediumLeetCodetodo
431Find the Connected Component in the Undirected GraphC++O(n)O(n)Mediumtodo
477Surrounded RegionsC++_O(m*n)_O(m+n)MediumLeetCode

Data Structure

PID#TitleSourceTimeSpaceDifficultyTagNote
134LRU CacheC++O(1)O(k)HardLeetCode, EPIList, Hash
PID#TitleSourceTimeSpaceDifficultyTagNote
90K Sum IIC++_O(k*C(n,k))_O(k)Medium
376Binary Tree Path SumC++O(n)O(h)EasyLeetCode
433Number of IslandsC++_O(m*n)__O(m*n)_EasyLeetCodeDFS
480Binary Tree PathsC++_O(n*h)_O(h)EasyLeetCode

Dynamic Programming

PID#TitleSourceTimeSpaceDifficultyTagNote
20Dices SumC++O(n^2 )O(n)Hardtodo
29Interleaving StringC++_O(m*n)_O(min(m,n))MediumEPI
43Maximum Subarray IIIC++_O(k*n)__O(k*n)_Hard
77Longest Common SubsequenceC++_O(m*n)_O(min(m,n))Medium
79Longest Common SubstringC++_O(m*n)_O(min(m,n))Medium
89K SumC++O(knt)_O(n*t)_Hard
91Minimum Adjustment CostC++O(knt)O(k)Medium
92BackpackC++_O(m*n)_O(m)Easy
107Word BreakC++_O(n*l^2 )_O(n)MediumLeetCode, EPItodo
108Palindrome Partitioning IIC++O(n^2 )O(n)MediumLeetCode, EPI
109TriangleC++O(n)O(n)EasyLeetCode, EPI
110Minimum Path SumC++_O(m*n)_O(min(m,n))EasyLeetCode, EPI
111Climbing StairsC++O(n)O(1)EasyLeetCode
115Unique Paths IIC++_O(m*n)_O(min(m,n))EasyLeetCode, CTCIDP, Math
118Distinct SubsequencesC++_O(m*n)_O(m)MediumLeetCodetodo
119Edit DistanceC++_O(m*n)_O(min(m,n))MediumLeetCode, CTCIDP
125Backpack IIC++_O(m*n)_O(m)Medium
149Best Time to Buy and Sell StockC++O(n)O(1)MediumLeetCode, EPI
150Best Time to Buy and Sell Stock IIC++O(n)O(1)MediumLeetCode, EPI
151Best Time to Buy and Sell Stock IIIC++O(n)O(1)MediumLeetCode, EPI
154Regular Expression MatchingC++_O(m*n)_O(m)HardLeetCodetodo
168Burst BalloonsC++O(n^3 )O(n^2 )MediumLeetCodetodo
191Maximum Product SubarrayC++O(n)O(1)MediumLeetCode
392House RobberC++O(n)O(1)MediumLeetCode
393Best Time to Buy and Sell Stock IVC++_O(k*n)_O(k)HardLeetCode, EPI
395Coins in a Line IIC++O(n)O(1)Medium
396Coins in a Line IIIC++O(n^2 )O(n)Hardtodo
397Longest Increasing Continuous subsequenceC++O(n)O(1)Easytodo
398Longest Increasing Continuous subsequence IIC++_O(m*n)__O(m*n)_Hardtodo
403Continuous Subarray Sum IIC++O(n)O(1)MediumEPItodo
430Scramble StringC++O(n^4 )O(n^3 )HardLeetCodetodo
435Post Office ProblemC++_O(k*n^2 )_O(n)HardPKU 1160todo
436Maximal SquareC++_O(m*n)_O(n)MediumLeetCodetodo
512Decode WaysC++O(n)O(1)MediumLeetCodetodo
513Perfect SquaresC++_O(n*sqrt(n))_O(n)MediumLeetCodetodo
514Paint FenceC++O(n)O(1)EasyLeetCodetodo
515Paint HouseC++O(n)O(1)MediumLeetCodetodo
516Paint House IIC++_O(n*k)_O(k)HardLeetCodetodo
534House Robber IIC++O(n)O(1)MediumLeetCodetodo
564Backpack VIC++_O(n*t)_O(t)Medium

Greedy

PID#TitleSourceTimeSpaceDifficultyTagNote
41Maximum SubarrayC++O(n)O(1)EasyLeetCode
42Maximum Subarray IIC++O(n)O(n)Medium
44Minimum SubarrayC++O(n)O(1)Easy
45Maximum Subarray DifferenceC++O(n)O(n)Medium
116Jump GameC++O(n)O(1)MediumLeetCode
117Jump Game IIC++O(n)O(1)MediumLeetCode
182Delete DigitsC++O(n)O(n)Medium
187Gas StationC++O(n)O(1)EasyLeetCodetodo
192Wildcard MatchingC++O(m+n)O(1)HardLeetCodetodo
402Continuous Subarray SumC++O(n)O(1)MediumEPI
412CandyC++O(n)O(n)HardLeetCodeGreedy
552Create Maximum NumberC++_O(k*(m+n+k))_ ~ _O(k*(m+n+k^2 ))_O(m+n+k^2 )HardLeetCodetodo

Hash Tables

PID#TitleSourceTimeSpaceDifficultyTagNote
562 SumC++O(n)O(n)MediumLeetCode
124Longest Consecutive SequenceC++O(n)O(n)MediumLeetCode, EPI
128Hash FunctionC++O(n)O(1)Easy
129RehashingC++O(n)O(n)Medium
138Subarray SumC++O(n)O(n)Easy
186Max Points on a LineC++O(n^2 )O(n)MediumLeetCode
211String PermutationC++O(n)O(1)Easytodo
384Longest Substring Without Repeating CharactersC++O(n)O(1)MediumLeetCode, EPI
386Longest Substring with At Most K Distinct CharactersC++O(n)O(n)Mediumtodo
432Find the Weak Connected Component in the Directed GraphC++O(nlogn)O(n)Mediumtodo
434Number of Islands IIC++O(k)O(k)Hardtodo
488Happy NumberC++O(k)O(k)EasyLeetCode
547Intersection of Two ArraysC++O(m+n)O(min(m,n))EasyEPI, LeetCodeTwo Pointers, Binary Search
548Intersection of Two Arrays IIC++O(m+n)O(min(m,n))EasyEPI, LeetCodeTwo Pointers, Binary Search

Heap

PID#TitleSourceTimeSpaceDifficultyTagNote
4Ugly Number IIC++O(n)O(1)MediumCTCIBST, Heap
81Data Stream MedianC++O(nlogn)O(n)HardEPIBST, Heap
130HeapifyC++O(n)O(1)Medium
364Trapping Rain Water IIC++O(mn(logm+logn))_O(m*n)_Hardtodo
518Super Ugly NumberC++_O(n*k)_O(n+k)MediumLeetCodetodo

Linked List

PID#TitleSourceTimeSpaceDifficultyTagNote
16Merge Two Sorted ListsC++O(n)O(1)EasyLeetCode, EPI
35Reverse Linked ListC++O(n)O(1)EasyLeetCode, EPI
36Reverse Linked List IIC++O(n)O(1)MediumLeetCode, EPI
96Partition ListC++O(n)O(1)EasyLeetCode
98Sort ListC++O(nlogn)O(logn)MediumLeetCode, EPItodo
99Reorder ListC++O(n)O(1)MediumLeetCode
102Linked List CycleC++O(n)O(1)MediumLeetCode
103Linked List Cycle IIC++O(n)O(1)HardLeetCodetodo
104Merge k Sorted ListsC++_O(n*logk)__O(1)_MediumLeetCodeHeap, Divide and Conquer
105Copy List with Random PointerC++O(n)O(1)MediumLeetCode
106Convert Sorted List to Binary Search TreeC++O(n)O(logn)MediumLeetCode, EPItodo
112Remove Duplicates from Sorted ListC++O(n)O(1)EasyLeetCode, EPI
113Remove Duplicates from Sorted List IIC++O(n)O(1)MediumLeetCode, EPI
166Nth to Last Node in ListC++O(n)O(1)EasyLeetCode
167Two Lists SumC++O(n)O(1)EasyLeetCodetodo
170Rotate ListC++O(n)O(1)MediumLeetCode
173Insertion Sort ListC++O(n^2 )O(1)EasyLeetCode
174Remove Nth Node From End of ListC++O(n)O(1)EasyLeetCode
223Palindrome Linked ListC++O(n)O(1)MediumLeetCode
372Delete Node in the Middle of Singly Linked ListC++O(1)O(1)EasyCTCI
380Intersection of Two Linked ListsC++O(m+n)O(1)EasyLeetCode
450Reverse Nodes in k-GroupC++O(n)O(1)HardLeetCode
451Swap Nodes in PairsC++O(n)O(1)EasyLeetCode
452Remove Linked List ElementsC++O(n)O(1)NaiveLeetCode
511Swap Two Nodes in Linked ListC++O(n)O(1)Mediumtodo

Math

PID#TitleSourceTimeSpaceDifficultyTagNote
2Trailing ZerosC++O(1)O(1)EasyLeetCode
3Digit CountsC++O(1)O(1)MediumCTCI
114Unique PathsC++O(min(m,n))O(1)EasyLeetCode, CTCIDP, Math
163Unique Binary Search TreesC++O(n)O(1)MediumCTCIDP, Math, Catalan Number
180Binary RepresentionC++O(1)O(1)HardCTCItodo
197Permutation IndexC++O(n^2 )O(1)Easy
198Permutation Index IIC++O(n^2 )O(n)Mediumtodo
394Coins in a LineC++O(1)O(1)Easy
411Gray CodeC++O(2^n )O(1)MediumLeetCodetodo
413Reverse IntegerC++O(1)O(1)MediumLeetCode
414Divide Two IntegerC++O(1)O(1)MediumLeetCode
418Integer to RomanC++O(n)O(1)MediumLeetCodetodo
419Roman to IntegerC++O(n)O(1)MediumLeetCodetodo
428Pow(x, n)C++O(1)O(1)MediumLeetCode
445Cosine SimilarityC++O(n)O(1)Easy
517Ugly NumberC++O(1)O(1)EasyCTCI, LeetCode

OO Design

PID#TitleSourceTimeSpaceDifficultyTagNote
204SingletonC++O(1)O(1)Easy
208Assignment Operator Overloading (C++ Only)C++O(n)O(1)Medium
496Toy FactoryC++O(1)O(1)Easy
497Shape FactoryC++O(1)O(1)Easy
498Parking LotC++O(nmk)O(nmk)HardCTCIOO Design, Pimpl Idiom, Smart Pointer

Queue

PID#TitleSourceTimeSpaceDifficultyTagNote
362Sliding Window MaximumC++O(n)O(k)HardEPIDeque, Tricky

Recursion

PID#TitleSourceTimeSpaceDifficultyTagNote
22Flatten ListC++O(n)O(h)Easy
72Construct Binary Tree from Inorder and Postorder TraversalC++O(n)O(n)MediumLeetCode, EPI
73Construct Binary Tree from Preorder and Inorder TraversalC++O(n)O(n)MediumLeetCode, EPI
93Balanced Binary TreeC++O(n)O(h)EasyLeetCode
94Binary Tree Maximum Path SumC++O(n)O(h)MediumLeetCode
95Validate Binary Search TreeC++O(n)O(h)MediumLeetCode
97Maximum Depth of Binary TreeC++O(n)O(h)EasyLeetCode
131Building OutlineC++O(nlogn)O(n)HardEPISort, BST
140Fast PowerC++O(logn)O(1)Medium
155Minimum Depth of Binary TreeC++O(n)O(h)EasyLeetCode
164Unique Binary Search Trees IIC++_O(n*4^n / n^(3/2) )_O(n)MediumLeetCode
177Convert Sorted Array to Binary Search Tree With Minimal HeightC++O(n)O(logn)EasyLeetCode
201Segment Tree BuildC++O(n)O(h)MediumSegment Tree, BST
202Segment Tree QueryC++O(h)O(h)MediumSegment Tree, BST
203Segment Tree ModifyC++O(h)O(h)MediumSegment Tree, BST
205Interval Minimum NumberC++build tree: O(n), query: (h)O(h)HardSegment Tree, BST
206Interval SumC++build tree: O(n), query: O(logn)O(n)HardSegment Tree, BIT
207Interval Sum IIC++build tree: O(n), query: O(logn), modify: O(logn)O(n)HardSegment Tree, BIT
245SubtreeC++_O(m*n)_O(1)EasyMorris Traversal
247Segment Tree Query IIC++O(h)O(h)HardSegment Tree, BST
248Count of Smaller NumberC++build tree: O(n), query: O(logn)O(h)MediumSegment Tree, BST
371Print Numbers by RecursionC++O(n)O(n)Medium
375Clone Binary TreeC++O(n)O(h)Easy
378Convert Binary Search Tree to Doubly Linked ListC++O(n)O(h)Medium
439Segment Tree Build IIC++O(n)O(h)MediumSegment Tree, BST
453Flatten Binary Tree to Linked ListC++O(n)O(h)EasyLeetCode
469Identical Binary TreeC++O(n)O(h)Easy
532Reverse PairsC++O(nlogn)O(n)Mediumvariant of Count of Smaller Number before itselfBIT, Merge Sort
535House Robber IIIC++O(n)O(h)MediumLeetCode

Sort

PID#TitleSourceTimeSpaceDifficultyTagNote
5Kth Largest ElementC++O(n) ~ O(n^2 )O(1)MediumEPITwo Pointers, Quick Sort
80MedianC++O(n)O(1)EasyEPI
139Subarray Sum ClosestC++O(nlogn)O(n)MediumSort
143Sort Colors IIC++O(n)O(1)Medium
148Sort ColorsC++O(n)O(1)MediumLeetCode
156Merge IntervalsC++O(nlogn)O(1)EasyLeetCode, EPI
184Largest NumberC++O(nlogn)O(1)MediumLeetCode
366FibonacciC++O(n)O(1)Easy
379Reorder array to construct the minimum numberC++O(nlogn)O(1)MediumLeetCode
387The Smallest DifferenceC++O(max(m,n) * log(min(m,n)))O(1)MediumTwo Pointers, Binary Search
399Nuts & Bolts ProblemC++O(nlogn)O(logn)MediumQuick Sort
400Maximum GapC++O(n)O(n)HardLeetCodeBucket Sort
463Sort IntegersC++O(n^2 )O(1)EasyInsertion Sort, Selection Sort, Bubble Sort
464Sort Integers IIC++O(nlogn)O(n)EasyMerge Sort, Heap Sort, Quick Sort
507Wiggle Sort IIC++O(n) on averageO(1)MediumLeetCodeTri Partition
508Wiggle SortC++O(n)O(1)MediumLeetCode

Stack

PID#TitleSourceTimeSpaceDifficultyTagNote
12Min StackC++O(n)O(1)MediumLeetCode, EPI
40Implement Queue by Two StacksC++O(1), amortizedO(n)MediumEPI
66Binary Tree Preorder TraversalC++O(n)O(1)EasyLeetCode, EPIMorris Traversal
67Binary Tree Inorder TraversalC++O(n)O(1)EasyLeetCode, EPIMorris Traversal
68Binary Tree Postorder TraversalC++O(n)O(1)EasyLeetCode, EPIMorris Traversal
122Largest Rectangle in HistogramC++O(n)O(n)HardLeetCode, EPIAscending Stack
126Max TreeC++O(n)O(n)HardDescending Stack
367Expression Tree BuildC++O(n)O(n)Hard
368Expression EvaluationC++O(n)O(n)Hard
369Convert Expression to Polish NotationC++O(n)O(n)Hard
370Convert Expression to Reverse Polish NotationC++O(n)O(n)Hard
421Simplify PathC++O(n)O(n)MediumLeetCode
423Valid ParenthesesC++O(n)O(n)EasyLeetCode
424Evaluate Reverse Polish NotationC++O(n)O(n)MediumLeetCode
473Add and Search WordC++O(min(n,h))O(min(n,h)MediumLeetCodeTrie
510Maximal RectangleC++_O(m*n)_O(n)HardLeetCodeAscending Stack
528Flatten Nested List IteratorC++O(n)O(h)MediumLeetCode

String

PID#TitleSourceTimeSpaceDifficultyTagNote
13strStrC++O(n+k)O(k)EasyLeetCodeKMP Algorithm
53Reverse Words in a StringC++O(n)O(1)EasyLeetCode, EPI
54String to Integer(atoi)C++O(n)O(1)HardLeetCode
55Compare StringsC++O(n)O(c)Easy
78Longest Common PrefixC++O(n)O(1)Medium
157Unique CharactersC++O(n)O(1)EasyCTCI
158Two Strings Are AnagramsC++O(n)O(1)Easy
171AnagramsC++_O(n*klogk)_O(m)EasyLeetCode, EPI
212Space ReplacementC++O(n)O(1)Easy
407Plus OneC++O(n)O(1)EasyLeetCode
408Add BinaryC++O(n)O(1)EasyLeetCode
415Valid PalindromeC++O(n)O(1)EasyLeetCode
417Valid NumberC++O(n)O(1)HardLeetCodeAutomata
420Count and SayC++_O(n*2^n )_O(2^n )EasyLeetCode
422Length of Last WordC++O(n)O(1)EasyLeetCode
524Left PadC++O(p+n)O(1)EasyLeetCode

System Design

PID#TitleSourceTimeSpaceDifficultyTagNote
501Mini TwitterC++O(klogu)O(t+f)Medium

Tree

PID#TitleSourceTimeSpaceDifficultyTagNote
7Binary Tree SerializationC++O(n)O(h)Medium
85Insert Node in a Binary Search TreeC++O(h)O(1)Easy
88Lowest Common AncestorC++O(n)O(h)MediumEPI
175Invert Binary TreeC++O(n)O(h)EasyLeetCode
442Implement TrieC++O(n)O(1)MediumLeetCodeTrie



第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台