1 Star 4 Fork 2

eudiwffes / lintcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Yet Another Source Code for LintCode

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

Notice

This Repository Was Merged in My Online Judge Collection and It Will Be Closed.

Algorithms

Array

PID# Title Source Time Space Level Tag Note
6 Merge Two Sorted Arrays C++ O(m+n) O(1) Easy LeetCode Merge
8 Rotate String C++ O(n) O(1) Easy LeetCode
9 Fizz Buzz C++ O(n) O(1) Easy Logic
30 Insert Interval C++ O(logn) O(1) Medium LeetCode Binary Search
31 Partition Array C++ O(n) O(1) Medium Partition
32 Minimum Window Substring C++ O(n) O(n) Medium LeetCode HashMap
38 Search a 2D Matrix II C++ O(m+n) O(1) Medium EPI Fast Search
39 Recover Rotated Sorted Array C++ O(n) O(1) Easy
46 Majority Number C++ O(n) O(1) Easy LeetCode
47 Majority Number II C++ O(n) O(1) Medium EPI HashMap
48 Majority Number III C++ O(n) O(k) Medium EPI HashMap
49 Sort Letters by Case C++ O(n) O(1) Medium Partition
50 Product of Array Exclude Itself C++ O(n) O(1) Easy LintCode State Store
51 Previous Permutation C++ O(n) O(1) Medium Permutation
52 Next Permutation C++ O(n) O(1) Medium LeetCode Permutation
57 3 Sum C++ O(n2) O(1) Medium LeetCode Two Pointers
58 4 Sum C++ O(n3) O(1) Medium LeetCode HashMap
59 3 Sum Closest C++ O(n2) O(1) Medium LeetCode Two Pointers
64 Merge Sorted Array C++ O(m+n) O(1) Easy LeetCode Merge
100 Remove Duplicates from
Sorted Array
C++ O(n) O(1) Easy LeetCode Two Pointers
101 Remove Duplicates from
Sorted Array II
C++ O(n) O(1) Easy LeetCode Two Pointers
133 Longest Words C++ O(n) O(n) Easy Greed
144 Interleaving Positive
and Negative Numbers
C++ O(n) O(1) Medium Two Pointers
161 Rotate Image C++ O(n2) O(1) Medium LeetCode Matrix
162 Set Matrix Zeroes C++ O(mn) O(1) Medium LeetCode State Transition
172 Remove Element C++ O(n) O(1) Easy LeetCode Two Pointers
185 Matrix Zigzag Traversal C++ O(mn) O(1) Easy Matrix
189 First Missing Positive C++ O(n) O(1) Easy LeetCode Hash
190 Next Permutation II C++ O(n) O(1) Medium LeetCode Permutation
200 Longest Palindromic Substring C++ O(n) O(n) Medium LeetCode Manacher,
Center Expand
278 Paint Fill C++ O(1) O(1) Easy
363 Trapping Rain Water C++ O(n) O(1) Medium LeetCode Two Pointers
373 Partition Array by Odd
and Even
C++ O(n) O(1) Easy Partition
374 Spiral Matrix C++ O(mn) O(1) Medium LeetCode Matrix
381 Spiral Matrix II C++ O(n2) O(1) Medium LeetCode Matrix
382 Triangle Count C++ Medium LintCode Two Points
383 Container With Most Water C++ O(n) O(1) Medium LeetCode Two Pointers
388 Permutation Sequence C++ O(n2) O(n) Medium LeetCode Permutation
389 Valid Sudoku C++ O(92) O(9) Easy LeetCode Sudoku
405 Submatrix Sum C++ O(mn2) O(m) Hard LintCode HashMap
406 Minimum Size Subarray Sum C++ O(n) O(1) Medium LeetCode Two Pointers,
Binary Search
479 Second Max of Array C++ O(n) O(1) Easy LeetCode
484 Swap Two Integers in Array C++ O(1) O(1) Naive LeetCode
539 Move Zeroes C++ O(n) O(1) Easy LeetCode Two Pointers
540 Zigzag Iterator C++ O(n) O(1) Medium Google
541 Zigzag Iterator II C++ O(n) O(1) Medium Google
601 Flatten 2D Vector C++ O(n) O(1) Medium Google Two Pointers
608 Two Sum II Input Array
Is Sorted
C++ O(n) O(1) Easy Amazon Two Pointers
633 Find The Duplicate Number C++ O(n2) O(1) Hard Bloomberg
645 Find The Celebrity C++ O(n) O(1) Medium LinkedIn,
Facebook
654 Sparse Matrix Multiplication C++ O(mn2) O(1) Medium LinkedIn,
Facebook
665 Range Sum Query 2D
Immutable
C++ O(mn) O(mn) Medium LintCode PrefixSum
692 Sliding Window Unique
Elements Sum
C++ O(n) O(n) Medium LintCode
698 Maximum Distance in
Arrays
C++ O(m) O(1) Medium LintCode
745 Palindromic Ranges C++ O(n) O(n) Easy LeetCode Two Pointers
767 Reverse Array C++ O(n) O(1) Easy LeetCode Two Pointers
769 Spiral Array C++ O(n2) O(n2) Easy LeetCode
770 Maximum and Minimum C++ O(n2) O(1) Easy LintCode
807 Palindrome Number II C++ O(1) O(1) Easy Amazon Two Pointers
817 Range Sum Query 2D Mutable C++ O(mn) O(mn) Medium Google PrefixSum
839 Merge Two Sorted Interval Lists C++ O(m+n) O(1) Easy LintCode Merge
840 Range Sum Query Mutable C++ O(nlogn) O(n) Medium Google BIT
846 Multi Keyword Sort C++ O(nlogn) O(1) Easy LintCode Sort
868 Maximum Average Subarray C++ O(n) O(1) Easy Google
888 Valid Word Square C++ O(mn) O(1) Easy Google
903 Range Addition C++ O(n) O(1) Medium Google
943 Range Sum Query Immutable C++ O(n) O(n) Easy Palantir PrefixSum
1001 Asteroid Collision C++ O(n) O(1) Medium Uber Stack
1042 Toeplitz Matrix C++ O(mn) O(1) Easy Google
1068 Find Pivot Index C++ O(n) O(1) Easy Radius PrefixSum
1099 Non Decreasing Array C++ O(n) O(1) Easy Google
1138 Can Place Flowers C++ O(n) O(1) Easy LinkedIn
1144 Range Addition II C++ O(n) O(1) Easy IXL
1157 Shortest Unsorted
Continuous Subarray
C++ O(n) O(1) Easy Google
1170 Reshape The Matrix C++ O(mn) O(mn) Easy Mathworks
1174 Next Greater Element III C++ O(1) O(1) Medium Bloomberg Permutation
1207 Teemo Attacking C++ O(n) O(1) Medium Riot
1225 Island Perimeter C++ O(mn) O(1) Easy Google
1282 Reverse Vowels of A String C++ O(n) O(1) Easy LeetCode Two Pointers
1310 Product of Array Except Itself C++ O(n) O(1) Easy Apple, Microsoft,
Facebook
1334 Rotate Array C++ O(n) O(1) Easy LeetCode

Backtracking

PID# Title Source Time Space Level Tag Note
15 Permutations C++ O(n*n!) O(n) Medium LeetCode Permutation
16 Permutations II C++ O(n*n!) O(n) Medium LeetCode Permutation
17 Subsets C++ O(n*2n) O(1) Medium LeetCode Backtracking
18 Subsets II C++ O(n*2n) O(1) Medium LeetCode Subset
33 N-Queens C++ O(n*n!) O(n) Medium LeetCode N-Queens
34 N-Queens II C++ O(n*n!) O(n) Medium LeetCode N-Queens
123 Word Search C++ O(mnl) O(l) Medium LeetCode Backtracking
132 Word Search II C++ O(mnl) O(l) Hard Trie, DFS
135 Combination Sum C++ O(knk) O(k) Medium LeetCode DFS
136 Palindrome Partitioning C++ O(2n) O(n) Easy LeetCode Substring
152 Combinations C++ O(knk) O(k) Medium LeetCode Combination
153 Combination Sum II C++ O(kC(n,k)) O(k) Medium LeetCode DFS
169 Tower of Hanoi C++ O(2n) O(2n) Medium LeetCode
425 Letter Combinations
of a Phone Number
C++ O(n*4n) O(n) Medium LeetCode Enumeration
426 Restore IP Addresses C++ O(1) O(1) Medium LeetCode Backtracking
427 Generate Parentheses C++ O(4n/n3/2) O(n) Medium LeetCode Backtracking
582 Word Break II C++ O(nl2) O(n) Hard Google, Twitter,
Uber, Snapchat
Backtrack
680 Split String C++ O(2n) O(2n) Medium LeetCode Backtracking
634 Word Squares C++ O(2n) O(nk) Hard Google Backtracking,
HashMap
749 Johns Backyard Garden C++ O(2n) O(2n) Easy LintCode Backtracking
836 Partition to K Equal
Sum Subsets
C++ O(2n) O(n) Easy LinkedIn Backtracking
913 Flip Game II C++ O(2n) O(2n) Medium Google
1032 Letter Case Permutation C++ O(2k) O(2k) Easy Yelp, Facebook Backtracking

Binary Search

PID# Title Source Time Space Level Tag Note
14 First Position of Target C++ O(logn) O(1) Easy Binary Search
28 Search a 2D Matrix C++ O(logm+logn) O(1) Easy LeetCode Matrix
60 Search Insert Position C++ O(logn) O(1) Easy LeetCode Lower Bound
61 Search for a Range C++ O(logn) O(1) Medium LeetCode Lower Bound
62 Search in Rotated
Sorted Array
C++ O(logn) O(1) Medium LeetCode only ascending
63 Search in Rotated
Sorted Array II
C++ O(logn) O(1) Medium LeetCode only ascending
65 Median of two Sorted Arrays C++ O(logm) O(1) Hard LeetCode kth-element,
merge
74 First Bad Version C++ O(logn) O(1) Medium Binary Search
75 Find Peak Element C++ O(logn) O(1) Medium LeetCode
76 Longest Increasing
Subsequence
C++ O(nlogn) O(n) Medium CTCI BS, DP
141 Sqrt(x) C++ O(logn) O(1) Easy LeetCode Newton Iteration
159 Find Minimum in Rotated
Sorted Array
C++ O(logn) O(1) Medium LeetCode only ascending
160 Find Minimum in Rotated
Sorted Array II
C++ O(logn) O(1) Medium LeetCode only ascending
183 Wood Cut C++ O(nlogL) O(1) Medium
248 Count of Smaller Number C++ O(n+klogn) O(h) Medium Segment Tree,
Binary Search
437 Copy Books C++ O(nk) O(1) Hard UVa 714 Binary Search
457 Classical Binary Search C++ O(logn) O(1) Easy Binary Search
460 Find K Closest Elements C++ O(nlogk) O(k) Medium Google Binary Search
641 Missing Ranges C++ O(logn) O(1) Medium Google Binary Search
662 Guess Number Higher
or Lower
C++ O(logn) O(1) Easy Google Binary Search
1219 Heaters C++ O(nlogn) O(1) Easy Google Binary Search

Binary Search Trees

PID# Title Source Time Space Level Tag Note
11 Search Range in Binary
Search Tree
C++ O(n) O(h) Medium EPI Branch Bound
86 Binary Search Tree Iterator C++ O(1) O(h) Hard LeetCode Stack
87 Remove Node in Binary
Search Tree
C++ O(h) O(h) Hard BST
249 Count of Smaller Number
before itself
C++ O(nlogn) O(n) Hard Segment Tree,
Binary Search
360 Sliding Window Median C++ O(nlogw) O(w) Hard BST
391 Number of Airplanes
in the Sky
C++ O(nlogn) O(n) Easy BST,
Heap, Sort
401 Kth Smallest Number in
Sorted Matrix
C++ O(klogm) O(m)) Medium Heap
448 Inorder Successor in BST C++ O(h) O(1) Medium LintCode BST
661 Convert BST to Greater
Tree
C++ O(n) O(1) Easy Amazon BST
689 Two Sum IV Input Is A
BST
C++ O(nh) O(n) Medium Google, Samsung,
Facebook
BST
691 Recover Binary Search
Tree
C++ O(n) O(1) Medium LintCode BST
701 Trim A Binary Search
Tree
C++ O(h) O(1) Medium LintCode BST
900 Closest Binary Search
Tree Value
C++ O(h) O(1) Easy Google BST
901 Closest Binary Search
Tree Value II
C++ O(n) O(n) Hard Google BST,
BinarySearch
902 Kth Smallest Element
in A BST
C++ O(n) O(1) Medium Google BST
1033 Minimum Difference
Between BST Nodes
C++ O(n) O(1) Easy Google BST,
BinarySearch
1188 Minimum Absolute
Difference in BST
C++ O(n) O(n) Easy Google BST

Bit Manipulation

PID# Title Source Time Space Level Tag Note
1 A + B Problem C++ O(1) O(1) Medium Bit Operator
82 Single Number C++ O(n) O(1) Easy LeetCode XOR
83 Single Number II C++ O(n) O(1) Easy LeetCode Bit Operator,
HashMap
84 Single Number III C++ O(n) O(1) Medium CTCI XOR, Bit
142 O(1) Check Power of 2 C++ O(1) O(1) Easy Bit
179 Update Bits C++ O(1) O(1) Medium CTCI Bit
181 Flip Bits C++ O(1) O(1) Easy CTCI
196 Find the Missing Number C++ O(n) O(1) Medium XOR
365 Count 1 in Binary C++ O(1) O(1) Easy CTCI
664 Counting Bits C++ O(n) O(n) Medium LintCode
723 Rotate Bits Left C++ O(1) O(1) Medium Facebook
782 And And Or C++ O(n) O(1) Medium Uber
1046 Prime Number of Set Bits
in Binary Representation
C++ O(n) O(1) Easy Amazon
1112 Set Mismatch C++ O(n) O(n) Easy Amazon
1218 Number Complement C++ O(n) O(1) Easy Cloudera
1253 Convert A Number to
Hexadecimal
C++ O(n) O(1) Easy LintCode
1266 Find The Difference C++ O(n) O(1) Easy Google
1332 Number of 1 Bits C++ O(1) O(1) Easy Apple, Microsoft

Breadth-First Search

PID# Title Source Time Space Level Tag Note
69 Binary Tree Level Order
Traversal
C++ O(n) O(n) Medium LeetCode BFS,
Queue
70 Binary Tree Level Order
Traversal II
C++ O(n) O(n) Medium LeetCode BFS,
Queue
71 Binary Tree Zigzag Level
Order Traversal
C++ O(n) O(n) Medium LeetCode BFS,
Queue
120 Word Ladder C++ O(nd) O(d) Medium LeetCode BFS, Queue
121 Word Ladder II C++ O(nd) O(d) Hard LeetCode BFS, DFS,
Multi-Tree
127 Topological Sorting C++ O(V+E) O(E) Medium BFS, Queue
137 Clone Graph C++ O(V+E) O(V) Medium BFS, DFS
176 Route Between Two Nodes
in Graph
C++ O(n) O(n) Medium DFS, BFS
178 Graph Valid Tree C++ O(V+E) O(V+E) Medium LeetCode BFS, Graph
477 Surrounded Regions C++ O(mn) O(1) Medium LeetCode DFS, BFS
573 Build Post Office II C++ O(n3) O(n) Hard Google, Zenefits BFS
605 Sequence Reconstruction C++ O(m+n) O(n) Medium Google, Airbnb BFS
615 Course Schedule C++ O(n) O(n) Medium Apple, Amazon BFS
663 Walls and Gates C++ O(mn) O(n) Medium Google, Facebook BFS
677 Number of Big Islands C++ O(mn) O(1) Medium BFS
698 Maximum Distance in
Arrays
C++ O(m) O(1) Medium LintCode
750 Portal C++ O(mn) O(k) Medium LintCode BFS
787 The Maze C++ O(mn) O(k) Medium Google BFS
788 The Maze II C++ O(mn) O(k) Medium NetEase, Google BFS
796 Open The Lock C++ O(104) O(104) Hard BFS
803 Shortest Distance
from All Buildings
C++ O(n3) O(n) Hard Google,
Zenefits
BFS
804 Number of Distinct
Islands II
C++ O(mn) O(k) Hard Amazon BFS
814 Shortest Path in Undirected
Graph
C++ O(mn) O(k) Medium LintCode BFS
860 Number of Distinct Islands C++ O(mn) O(k) Medium Amazon BFS
872 Kill Process C++ O(n) O(n) Easy Bloomberg BFS
1062 Flood Fill C++ O(mn) O(mn) Easy Uber BFS
1071 Longest Word in Dictionary C++ O(nlogn) O(n) Easy Pinterest BFS
1080 Max Area of Island C++ O(mn) O(n) Easy Intuit BFS

Data Structure

PID# Title Source Time Space Level Tag Note
24 LFU Cache C++ O(n) O(k) Hard Google HashMap, MultiMap
134 LRU Cache C++ O(1) O(k) Hard LeetCode List, HashMap
657 Insert Delete
Getrandom O1
C++ O(1) O(n) Medium Twitter, Facebook,
Amazon, Google
HashMap

Depth-First Search

PID# Title Source Time Space Level Tag Note
90 K Sum II C++ O(kC(n,k)) O(k) Medium DFS
376 Binary Tree Path Sum C++ O(n) O(h) Easy LeetCode DFS
430 Scramble String C++ O(n^3) O(n^3) Hard DFS
433 Number of Islands C++ O(mn) O(1) Easy LeetCode DFS
480 Binary Tree Paths C++ O(nh) O(h) Easy LeetCode DFS
551 Nested List Weight Sum C++ O(n) O(h) Easy LeetCode DFS
570 Find The Missing Number II C++ O(n!) O(1) Medium LintCode
790 Parser C++ O(2n) O(1) Medium LintCode
1795 Is Possible C++ O(n) O(1) Medium LintCode DFS

Dynamic Programming

PID# Title Source Time Space Level Tag Note
20 Dices Sum C++ O(n2) O(n) Hard
29 Interleaving String C++ O(mn) O(1) Medium EPI DP, DFS
43 Maximum Subarray III C++ O(kn) O(kn) Hard LintCode DP
77 Longest Common Subsequence C++ O(mn) O(m) Medium LintCode LCS, DP
79 Longest Common Substring C++ O(mn) O(m) Medium LintCode LCS, DP
89 K Sum C++ O(knt) O(nt) Hard DP
91 Minimum Adjustment Cost C++ O(knt) O(k) Medium LintCode DP
92 Backpack C++ O(mn) O(m) Easy DP
107 Word Break C++ O(nl2) O(n) Medium LeetCode
108 Palindrome Partitioning II C++ O(n2) O(n) Medium LeetCode DP
109 Triangle C++ O(n) O(n) Easy LeetCode DP
110 Minimum Path Sum C++ O(mn) O(1) Easy LeetCode DP
111 Climbing Stairs C++ O(n) O(1) Easy LeetCode Fibonacci
115 Unique Paths II C++ O(mn) O(m) Easy LeetCode DP
118 Distinct Subsequences C++ O(mn) O(m) Medium LeetCode DP
119 Edit Distance C++ O(mn) O(m)) Medium LeetCode DP
125 Backpack II C++ O(mn) O(m) Medium DP
149 Best Time to Buy and
Sell Stock
C++ O(n) O(1) Medium LeetCode Greedy
150 Best Time to Buy and
Sell Stock II
C++ O(n) O(1) Medium LeetCode Greedy
151 Best Time to Buy and
Sell Stock III
C++ O(n) O(1) Medium LeetCode
154 Regular Expression Matching C++ O(mn) O(m) Hard LeetCode Recursion,
DP, Regex
168 Burst Balloons C++ O(n3) O(n2) Medium LeetCode DP
191 Maximum Product Subarray C++ O(n) O(1) Medium LeetCode
392 House Robber C++ O(n) O(1) Medium LeetCode DP
393 Best Time to Buy and
Sell Stock IV
C++ O(kn) O(k) Hard LeetCode DP
395 Coins in a Line II C++ O(n) O(1) Medium DP
397 Longest Continuous
Increasing Subsequence
C++ O(n) O(1) Easy DP
398 Longest Increasing
Continuous subsequence II
C++ O(mn) O(mn) Hard todo
403 Continuous Subarray Sum II C++ O(n) O(1) Medium EPI todo
430 Scramble String C++ O(n4) O(n3) Hard LeetCode todo
435 Post Office Problem C++ O(kn2) O(n) Hard PKU 1160 todo
436 Maximal Square C++ O(mn) O(n) Medium Apple,
Facebook
476 Stone Game C++ O(n3) O(n2) Medium LeetCode DP
512 Decode Ways C++ O(n) O(1) Medium Microsoft,
Google,
Facebook
513 Perfect Squares C++ O(n1.5) O(n) Medium Google DP
515 Paint House C++ O(n) O(1) Medium LinkedIn
516 Paint House II C++ O(nk) O(k) Hard Facebook
534 House Robber II C++ O(n) O(1) Medium LeetCode
553 Bomb Enemy C++ O(mn) O(n) Medium Google
562 Backpack IV C++ O(mn) O(m) Medium DP
563 Backpack V C++ O(mn) O(m) Medium DP
564 Combination Sum
IV(Backpack VI)
C++ O(nt) O(t) Medium Google,
Facebook
588 Partition Equal Subset Sum C++ O(n*sum) O(sum) Medium eBuy, Amazon DP
603 Largest Divisible Subset C++ O(n2) O(n) Medium LintCode
666 Guess Number Higher or
Lower II
C++ O(n2) O(n2) Medium Google DP
667 Longest Palindromic
Subsequence
C++ O(n2) O(n) Medium Amazon, Uber DP, Memorized
Search
669 Coin Change C++ O(nk) O(k) Medium LintCode
670 Predict The Winner C++ O(n2) O(n2) Medium Google DP
676 Decode Ways II C++ O(1) O(1) Hard Facebook
679 Unique Paths III C++ O(mn) O(m) Hard Amazon DP,HashSet
683 Word Break III C++ O(n2) O(n) Medium LintCode DP
734 Number of Subsquences of
Form Ai Bj Ck
C++ O(n) O(n) Medium Amazon DP
740 Coin Change 2 C++ O(nk) O(k) Medium LintCode
866 Coin Path C++ O(nB) O(n) Hard Google DP
885 Encode String with Shortest
Length
C++ O(n3) O(n2) Hard Google DP
1044 Largest Plus Sign C++ O(n2) O(n2) Medium Facebook DP
1054 Min Cost Climbing Stairs C++ O(n) O(n) Easy Amazon DP

Greedy

PID# Title Source Time Space Level Tag Note
41 Maximum Subarray C++ O(n) O(1) Easy LeetCode
42 Maximum Subarray II C++ O(n) O(n) Medium Two Pointers
44 Minimum Subarray C++ O(n) O(1) Easy
45 Maximum Subarray Difference C++ O(n) O(n) Medium Two Pointers
116 Jump Game C++ O(n) O(1) Medium LeetCode
117 Jump Game II C++ O(n) O(1) Medium LeetCode
182 Delete Digits C++ O(n) O(n) Medium
187 Gas Station C++ O(n) O(1) Easy LeetCode
192 Wildcard Matching C++ O(m+n) O(1) Hard LeetCode Backtracking, DP
402 Continuous Subarray Sum C++ O(n) O(1) Medium EPI
412 Candy C++ O(n) O(n) Hard LeetCode Greedy
761 Smallest Subset C++ O(n) O(1) Medium LintCode Greedy
797 Reach A Number C++ O(n) O(1) Easy inmobi Greedy
1230 Assign Cookies C++ O(nlogn) O(1) Easy LintCode

Hash Tables

PID# Title Source Time Space Level Tag Note
56 Two Sum C++ O(n) O(n) Medium LeetCode HashMap
124 Longest Consecutive Sequence C++ O(n) O(n) Medium LeetCode HashSet
128 Hash Function C++ O(n) O(1) Easy
129 Rehashing C++ O(n) O(n) Medium
131 The Skyline Problem C++ O(nlogn) O(n) Hard LeetCode HashSet
138 Subarray Sum C++ O(n) O(n) Easy HashMap
186 Max Points on a Line C++ O(n2) O(n) Medium LeetCode HashMap
209 First Unique Character in
A String
C++ O(n) O(n) Easy HashMap
211 String Permutation C++ O(n) O(1) Easy
384 Longest Substring Without
Repeating Characters
C++ O(n) O(1) Medium LeetCode
386 Longest Substring with At
Most K Distinct Characters
C++ O(n) O(n) Medium HashMap
434 Number of Islands II C++ O(k) O(mn) Hard UFS
488 Happy Number C++ O(k) O(k) Easy LeetCode
547 Intersection of Two Arrays C++ O(m+n) O(m) Easy LeetCode HashSet
548 Intersection of Two Arrays II C++ O(m+n) O(m) Easy LeetCode HashMap
550 Top K Frequent Words II C++ O(n+k) O(nlogk) Hard LintCode HashMap
627 Longest Palindrome C++ O(n) O(1) Easy HashMap
638 Isomorphic Strings C++ O(n) O(n) Easy LinkedIn HashMap
639 Word Abbreviation C++ O(n) O(n) Hard Google,
Snapchat
HashMap
646 First Position Unique
Character
C++ O(n) O(n) Easy HashMap
647 Find All Anagrams in A
String
C++ O(mn) O(m) Easy Amazon HashMap
648 Unique Word Abbreviation C++ O(n) O(n) Medium Google HashMap
671 Rotate Words C++ O(nk) O(n) Easy LintCode HashCode
684 Missing String C++ O(m) O(m+n) Easy Twitter HashMap
685 First Unique Number in
Data Stream
C++ O(n) O(n) Medium LintCode HashMap
702 Concatenated String with Uncommon
Characters of Two Strings
C++ O(n) O(n) Easy Microsoft HashMap
720 Rearrange A String with Integers C++ O(n) O(n) Easy Facebook HashMap
737 Find Elements in Matrix C++ O(mn) O(n) Easy LintCode HashMap
772 Group Anagrams C++ O(nklogk) O(n) Easy Amazon HashMap
774 Repeated DNA C++ O(n) O(n) Medium LinkedIn HashMap
775 Palindrome Pairs C++ O(nk) O(n) Hard Google, Airbnb HashMap
813 Find Anagram Mappings C++ O(n) O(n) Easy Google HashMap
828 Word Pattern C++ O(n) O(n) Easy Uber HashMap
838 Subarray Sum Equals K C++ O(n) O(n) Easy Google HashMap
856 Sentence Similarity C++ O(n) O(n) Easy Google HashMap
908 Line Reflection C++ O(n) O(n) Easy Google HashMap
960 First Unique Number in
Data Stream II
C++ O(n) O(n) Medium LintCode HashMap
1006 Subdomain Visit Count C++ O(n) O(n) Easy Roblox HashMap
1038 Jewels and Stones C++ O(n) O(n) Easy Amazon HashMap
1078 Degree of An Array C++ O(nlogn) O(n) Easy Amazon HashMap
1143 Minimum Index Sum of
Two Lists
C++ O(m+n) O(m) Easy Yelp HashMap
1148 Longest Harmonious Subsequence C++ O(n) O(n) Easy LiveRamp HashMap
1163 Distribute Candies C++ O(n) O(n) Easy LiveRamp HashMap
1169 Permutation in String C++ O(mn) O(m) Medium Microsoft HashMap
1187 K Diff Pairs in An Array C++ O(n) O(n) Easy Amazon HashMap
1237 Number of Boomerangs C++ O(n2) O(n) Easy Google HashMap
1270 Ransom Note C++ O(n) O(128) Easy Apple HashMap
1319 Contains Duplicate II C++ O(n) O(n) Easy Airbnb, Yahoo HashMap
1320 Contains Duplicate C++ O(n) O(n) Easy Airbnb, Yahoo HashMap
1369 Most Common Word C++ O(n) O(n) Easy Amazon HashMap
1443 Longest AB Substring C++ O(n) O(n) Easy Alibaba HashMap
1713 Unique Email Addresses C++ O(m) O(m) Easy Google HashMap
1728 X of A Kind in A Deck
of Cards
C++ O(n) O(n) Easy LeetCode HashMap
1779 Shortest Duplicate Subarray C++ O(m) O(m) Easy Google HashMap

Heap

PID# Title Source Time Space Level Tag Note
4 Ugly Number II C++ O(n) O(1) Medium CTCI DP, Heap
81 Find Median from Data Stream C++ O(nlogn) O(n) Hard EPI Heap
130 Heapify C++ O(n) O(1) Medium Heap
364 Trapping Rain Water II C++ O(mnlogmn)) O(mn) Hard BFS, Heap
471 Top K Frequent Words C++ O(nlogk) O(n) Medium Heap
486 Merge K Sorted Arrays C++ O(nlogk) O(n) Medium Heap
518 Super Ugly Number C++ O(nk) O(n+k) Medium LeetCode Heap
549 Top K Frequent Words
Map Reduce
C++ O(nlogk) O(k) Medium LeetCode Heap,
Set
577 Merge K Sorted Interval Lists C++ O(nlogk) O(n) Medium Airbnb Heap
612 K Closest Points C++ O(nlogk) O(k) Medium LinkedIn,
Amazon
Heap

Linked List

PID# Title Source Time Space Level Tag Note
165 Merge Two Sorted Lists C++ O(n) O(1) Easy LeetCode Merge Sort
35 Reverse Linked List C++ O(n) O(1) Easy LeetCode
36 Reverse Linked List II C++ O(n) O(1) Medium LeetCode
96 Partition List C++ O(n) O(1) Easy LeetCode
98 Sort List C++ O(nlogn) O(logn) Medium LeetCode Merge Sort,
Quick Sort
99 Reorder List C++ O(n) O(1) Medium LeetCode Two pointers
102 Linked List Cycle C++ O(n) O(1) Medium LeetCode Two Pointers
103 Linked List Cycle II C++ O(n) O(1) Hard LeetCode Tow Pointers
104 Merge k Sorted Lists C++ O(nlogk) O(1) Medium LeetCode Merge
105 Copy List with Random Pointer C++ O(n) O(1) Medium LeetCode InPlace,
HashMap
106 Convert Sorted List to
Balanced Binary Search Tree
C++ O(n) O(logn) Medium LeetCode
112 Remove Duplicates from
Sorted List
C++ O(n) O(1) Easy LeetCode
113 Remove Duplicates from
Sorted List II
C++ O(n) O(1) Medium LeetCode
166 Nth to Last Node in List C++ O(n) O(1) Easy LeetCode
167 Add Two Numbers C++ O(n) O(1) Easy LeetCode
170 Rotate List C++ O(n) O(1) Medium LeetCode
173 Insertion Sort List C++ O(n2) O(1) Easy LeetCode
174 Remove Nth Node From
End of List
C++ O(n) O(1) Easy LeetCode Two Pointers
219 Insert Node in Sorted
Linked List
C++ O(n) O(1) Easy LintCode
221 Add Two Numbers ii C++ O(n) O(1) Medium LeetCode
223 Palindrome Linked List C++ O(n) O(1) Medium LeetCode Reverse List
372 Delete Node in the Middle
of Singly Linked List
C++ O(1) O(1) Easy CTCI
380 Intersection of Two Linked Lists C++ O(m+n) O(1) Easy LeetCode
450 Reverse Nodes in k-Group C++ O(n) O(1) Hard LeetCode Reverse List
451 Swap Nodes in Pairs C++ O(n) O(1) Easy LeetCode Two Pointers
452 Remove Linked List Elements C++ O(n) O(1) Naive LeetCode
466 Count Linked List Nodes C++ O(n) O(1) Naive LeetCode
511 Swap Two Nodes in Linked List C++ O(n) O(1) Medium
599 Insert into A Cyclic Sorted List C++ O(n) O(n) Medium Alibaba HashSet
822 Reverse Order Storage C++ O(n) O(n) Easy LintCode

Math

PID# Title Source Time Space Level Tag Note
2 Trailing Zeros C++ O(logn) O(1) Easy LeetCode
3 Digit Counts C++ O(logn) O(1) Medium CTCI
37 Reverse 3 Digit Integer C++ O(1) O(1) Naive LintCode
114 Unique Paths C++ O(m) O(1) Easy LeetCode DP, Math
163 Unique Binary Search Trees C++ O(n) O(1) Medium CTCI Catalan
180 Binary Represention C++ O(n2) O(n+m) Hard CTCI Math
197 Permutation Index C++ O(n2) O(1) Easy Cantor Expand
198 Permutation Index II C++ O(n2) O(n) Medium Cantor Expand
254 Drop Eggs C++ O(1) O(1) Easy Tencent Math
283 Max of 3 Numbers C++ O(1) O(1) Naive
394 Coins in a Line C++ O(1) O(1) Easy
411 Gray Code C++ O(2n) O(1) Medium LeetCode XOR
413 Reverse Integer C++ O(1) O(1) Medium LeetCode
414 Divide Two Integer C++ O(1) O(1) Medium LeetCode
418 Integer to Roman C++ O(n) O(1) Medium LeetCode Roman Number
419 Roman to Integer C++ O(n) O(1) Medium LeetCode Roman Number
428 Pow(x, n) C++ O(1) O(1) Medium LeetCode Fast Pow
454 Rectangle Area JAVA O(1) O(1) Naive LeetCode
445 Cosine Similarity C++ O(n) O(1) Easy
514 Paint Fence C++ O(n) O(1) Easy Google DP
517 Ugly Number C++ O(1) O(1) Easy LeetCode
569 Add Digits C++ O(1) O(1) Easy
626 Rectangle Overlap C++ O(1) O(1) Easy LintCode
681 First Missing Prime Number C++ O(nlogn) O(1) Easy LintCode
690 Factorial C++ O(n) O(n) Hard Fast Factorial
697 Sum of Square Numbers C++ O(n) O(1) Easy LinkedIn Two Points
699 Check Sum of K
Primes
C++ O(1) O(1) Hard Goldbach Conjecture Math
706 Binary Watch C++ O(720*7) O(720) Medium Google Bit
728 Three Distinct Factors C++ O(n) O(1) Medium Prime
729 Last Digit by
Factorial Divide
C++ O(n) O(1) Meidum Google Math
730 Sum of All Subsets C++ O(1) O(1) Easy Bloomberg Math
739 24 Game C++ O(n!) O(1) Medium Google BFS
742 Self Dividing Numbers C++ O(n) O(1) Medium
744 Sum of K Even Length
Palindrome Numbers
C++ O(n) O(1) Medium Facebook
763 Hex Conversion C++ O(logn) O(1) Easy
764 Calculate Circumference
and Area
C++ O(1) O(1) Easy LintCode
765 Valid Triangle C++ O(1) O(1) Easy
766 Leap Year C++ O(1) O(1) Easy
768 Yang Hui Triangle C++ O(n2) O(n2) Easy
777 Valid Perfect Square C++ O(1) O(1) Easy
779 Generalized Abbreviation C++ O(2k) O(2k) Medium Google Binary
792 Kth Prime Number C++ O(n2) O(n) Easy Math
835 Hamming Distance C++ O(1) O(1) Easy Facebook Math
845 Greatest Common Divisor C++ O(k) O(1) Easy LintCode Math
918 3 Sum Smaller C++ O(n2) O(1) Medium Google Sort
949 Fibonacci II C++ O(logn) O(1) Medium LintCode MatrixCal
973 1 Bit and 2 Bit Characters C++ O(1) O(1) Easy
977 Base 7 C++ O(logn) O(logn) Easy LintCode
983 Baseball Game C++ O(n) O(n) Easy Amazon Stack
987 Binary Number with
Alternating Bits
C++ O(logn) O(1) Easy Yahoo
988 Arranging Coins C++ O(1) O(1) Easy GoDaddy Math
1005 Largest Triangle Area C++ O(n3) O(1) Easy Google Math
1017 Similar RGB Color C++ O(16) O(1) Easy Google
1023 Preimage Size of Factorial
Zeroes Function
C++ O(logK) O(1) Hard Adobe Binary Search
1192 Longest Uncommon
Subsequence I
C++ O(1) O(1) Easy Google
1199 Perfect Number C++ O(sqrt(n)) O(1) Easy Fallible
1209 Construct The Rectangle C++ O(sqrt(n)) O(1) Easy LintCode
1216 Largest Palindrome Product C++ O(pow(n)) O(1) Easy Yahoo Math
1217 Total Hamming Distance C++ O(1) O(1) Medium Facebook Math
1228 Poor Pigs C++ O(1) O(1) Easy LintCode Math
1256 Nth Digit C++ O(1) O(1) Easy Google Math
1277 Water and Jug Problem C++ O(n) O(1) Medium Microsoft Math
1285 Power of Four C++ O(1) O(1) Easy Two Sigma Math
1286 Self Crossing C++ O(n) O(1) Hard LintCode Math
1294 Power of Three C++ O(1) O(1) Easy Google Math
1300 Nim Game C++ O(1) O(1) Easy Adobe
1314 Power of Two C++ O(1) O(1) Easy Google Bit
1324 Count Primes C++ O(nloglogn) O(n) Easy Amazon,
Microsoft
1347 Factorial Trailing Zeroes C++ O(logn) O(1) Easy Bloomberg
1348 Excel Sheet Column Number C++ O(n) O(1) Easy Uber,
Microsoft
1350 Excel Sheet Column Title C++ O(n) O(1) Easy Fackbook,
Microsoft
1354 Pascals Triangle II C++ O(k) O(k) Easy LintCode
1385 Lucky Number Eight C++ O(n) O(1) Easy LintCode

OO Design

PID# Title Source Time Space Level Tag Note
204 Singleton C++ O(1) O(1) Easy
208 Assignment Operator Overloading
(C++ Only)
C++ O(n) O(1) Medium
496 Toy Factory C++ O(1) O(1) Easy

Queue

PID# Title Source Time Space Level Tag Note
362 Sliding Window Maximum C++ O(n) O(k) Hard EPI Deque, Multiset
642 Moving Average from
Data Stream
C++ O(n) O(n) Easy Queue
791 Merge Number C++ O(n) O(k) Medium LintCode
1109 Dota2 Senate C++ O(n2) O(n) Medium Valve Queue

Recursion

PID# Title Source Time Space Level Tag Note
22 Flatten List C++ O(n) O(h) Easy
72 Construct Binary Tree from
Inorder and Postorder Traversal
C++ O(n) O(n) Medium LeetCode
73 Construct Binary Tree from
Preorder and Inorder Traversal
C++ O(n) O(n) Medium LeetCode Binary Tree
93 Balanced Binary Tree C++ O(n) O(h) Easy LeetCode
94 Binary Tree Maximum Path Sum C++ O(n) O(h) Medium LeetCode
95 Validate Binary Search Tree C++ O(n) O(h) Medium LeetCode
97 Maximum Depth of Binary Tree C++ O(n) O(h) Easy LeetCode
131 The Skyline Problem
(Building Outline)
C++ O(nlogn) O(n) Hard EPI todo
140 Fast Power C++ O(logn) O(1) Medium
155 Minimum Depth of Binary Tree C++ O(n) O(h) Easy LeetCode
164 Unique Binary Search Trees II C++ O(n0.5*4n) O(n) Medium LeetCode DFS
177 Convert Sorted Array to Binary
Search Tree With Minimal Height
C++ O(n) O(logn) Easy LeetCode
201 Segment Tree Build C++ O(n) O(h) Medium Segment Tree
202 Segment Tree Query C++ O(h) O(h) Medium Segment Tree
203 Segment Tree Modify C++ O(h) O(h) Medium Segment Tree
205 Interval Minimum Number C++ O(n+klogh) O(h) Medium Segment Tree
206 Interval Sum C++ O(n+klogn) O(n) Medium Segment Tree,
Prefix-sum
207 Interval Sum II C++ O(n+klogn) O(n) Hard Segment Tree
227 Mock Hanoi Tower by Stacks C++ O(2n) O(2n) Easy Recursion,
Stack
245 Subtree C++ O(mn) O(1) Easy Pre-order
247 Segment Tree Query II C++ O(h) O(h) Medium Segment Tree
371 Print Numbers by Recursion C++ O(n) O(n) Medium
375 Clone Binary Tree C++ O(n) O(h) Easy Pre-order
378 Convert Binary Search Tree
to Doubly Linked List
C++ O(n) O(h) Medium In-order
439 Segment Tree Build II C++ O(n) O(h) Medium Segment Tree
453 Flatten Binary Tree to
Linked List
C++ O(n) O(h) Easy LeetCode
469 Same Tree(Identical Binary Tree) C++ O(n) O(h) Easy Pre-order
532 Reverse Pairs C++ O(nlogn) O(n) Medium LintCode Binary Search
575 Decode String C++ O(n) O(n) Medium Google,
Facebook
Recursion
535 House Robber III C++ O(n) O(h) Medium LeetCode Post-order
650 Find Leaves of Binary Tree C++ O(n) O(1) Medium LinkedIn Binary Tree

Sort

PID# Title Source Time Space Level Tag Note
5 Kth Largest Element C++ O(n) O(1) Medium EPI Partition
80 Median C++ O(n) O(1) Easy EPI Partition
139 Subarray Sum Closest C++ O(nlogn) O(n) Medium Prefix Sum
143 Sort Colors II C++ O(n) O(1) Medium Radix Sort
148 Sort Colors C++ O(n) O(1) Medium LeetCode Radix Sort
156 Merge Intervals C++ O(nlogn) O(1) Easy LeetCode
184 Largest Number C++ O(nlogn) O(1) Medium LeetCode Sort
366 Fibonacci C++ O(n) O(1) Easy
379 Reorder Array to Construct
The Minimum Number
C++ O(nlogn) O(1) Medium LeetCode Sort
387 The Smallest Difference C++ O(mlogm) O(1) Medium LintCode Two Pointers
399 Nuts & Bolts Problem C++ O(nlogn) O(logn) Medium Quick Sort,
Select Sort
400 Maximum Gap C++ O(nlogn) O(n) Hard LeetCode Quick Sort
463 Sort Integers C++ O(n2 ) O(1) Easy Insertion Sort,
Selection Sort,
Bubble Sort
464 Sort Integers II C++ O(nlogn) O(n) Easy Merge Sort,
Heap Sort,
Quick Sort
503 Anagram Map Reduce C++ O(n) O(n) Medium LeetCode Sort
506 Movie Recommendation C++ O(n^2) O(n) Medium LeetCode Set
507 Wiggle Sort II C++ O(n) O(1) Medium LeetCode todo
508 Wiggle Sort C++ O(n) O(1) Medium LeetCode
554 Sort Integers Map Reduce C++ O(nlogn) O(1) Medium LeetCode
912 Best Meeting Point C++ O(mn) O(m+n) Hard Twitter Sort
919 Meeting Rooms II C++ O(nlogn) O(n) Medium Facebook Sort
920 Meeting Rooms C++ O(nlogn) O(1) Easy Facebook HashSet
993 Array Partition I C++ O(nlogn) O(1) Easy Sort
1119 Maximum Product of Three
Numbers
C++ O(nlogn) O(1) Easy Intuit Sort
1200 Relative Ranks C++ O(nlogn) O(n) Easy Sort
1231 Minimum Moves to Equal
Array Elements
C++ O(nlogn) O(1) Easy Indeed Sort
1236 Find All Numbers Disappeared
in An Array
C++ O(nlogn) O(1) Easy Google Sort
1318 Contains Duplicate III C++ O(nlogn) O(n) Easy Airbnb Sort

Stack

PID# Title Source Time Space Level Tag Note
12 Min Stack C++ O(n) O(1) Medium LeetCode
40 Implement Queue by Two Stacks C++ O(1) O(n) Medium EPI
66 Binary Tree Preorder Traversal C++ O(n) O(1) Easy LeetCode
67 Binary Tree Inorder Traversal C++ O(n) O(1) Easy LeetCode
68 Binary Tree Postorder Traversal C++ O(n) O(1) Easy LeetCode
122 Largest Rectangle in Histogram C++ O(n) O(n) Hard LeetCode MiniStack
367 Expression Tree Build C++ O(n) O(n) Hard Stack
368 Expression Evaluation C++ O(n) O(n) Hard Stack
370 Convert Expression to
Reverse Polish Notation
C++ O(n) O(n) Hard Stack
421 Simplify Path C++ O(n) O(n) Medium LeetCode
423 Valid Parentheses C++ O(n) O(n) Easy LeetCode
424 Evaluate Reverse Polish
Notation
C++ O(n) O(n) Medium LeetCode Stack
473 Add and Search Word Data
Structure Design
C++ O(h) O(h) Medium LeetCode Trie Tree
510 Maximal Rectangle C++ O(mn) O(n) Hard LeetCode MiniStack
528 Flatten Nested List Iterator C++ O(n) O(h) Medium LeetCode Stack
636 132 Pattern C++ O(nk) O(k) Medium LeetCode Stack
834 Remove Duplicate Letters C++ O(n) O(n) Easy Google Stack
1201 Next Greater Element II C++ O(n) O(n) Medium Google Stack
1206 Next Greater Element I C++ O(n) O(n) Easy LintCode Stack

String

PID# Title Source Time Space Level Tag Note
13 Implement strStr C++ O(n+k) O(k) Easy LeetCode KMP
53 Reverse Words in a String C++ O(n) O(1) Easy LeetCode Stack
54 String to Integer Atoi C++ O(n) O(1) Hard LeetCode
55 Compare Strings C++ O(n) O(c) Easy Hash
78 Longest Common Prefix C++ O(n) O(1) Medium
145 Lowercase to Uppercase C++ O(n) O(1) Naive LintCode ASCII
157 Unique Characters C++ O(n) O(1) Easy CTCI Hash
158 Valid Anagram
(Two Strings Are Anagrams)
C++ O(n) O(1) Easy Hash
171 Anagrams C++ O(nklogk) O(m) Easy LeetCode Sort,Hash
212 Space Replacement C++ O(n) O(1) Easy
213 String Compression C++ O(n) O(n) Easy
407 Plus One C++ O(n) O(1) Easy LeetCode
408 Add Binary C++ O(n) O(1) Easy LeetCode
415 Valid Palindrome C++ O(n) O(1) Easy LeetCode
417 Valid Number C++ O(n) O(1) Easy LinkedIn Regex
420 Count and Say C++ O(n*2n) O(2n) Easy LeetCode
422 Length of Last Word C++ O(n) O(1) Easy LeetCode
491 Palindrome Number C++ O(1) O(1) Easy LeetCode
524 Left Pad C++ O(p+n) O(1) Easy LeetCode
594 strStr II C++ O(n+k) O(k) Easy LeetCode KMP
637 Valid Word Abbreviation C++ O(n) O(1) Easy LeetCode
640 One Edit Distance C++ O(n) O(1) Medium Facebook
643 Longest Absolute File Path C++ O(n) O(n) Medium Google
644 Strobogrammatic Number C++ O(n) O(1) Easy LeetCode
655 Add Strings C++ O(n) O(1) Easy LeetCode
656 Multiply Strings C++ O(mn) O(1) Medium LeetCode
659 Encode and Decode Strings C++ O(n) O(n) Medium Google
678 Shortest Palindrome C++ O(n2) O(1) Medium Google
686 Remove Arbitrary C++ O(n) O(1) Easy LintCode
688 The Number in Words C++ O(1) O(1) Medium LintCode
719 Calculate Maximum Value C++ O(n) O(1) Medium LeetCode
776 Strobogrammatic Number II C++ O(n) O(n) Medium Google Backtrack
784 The Longest Common Prefix II C++ O(nk) O(1) Easy LintCode
812 Bold Words i String C++ O(nk) O(m) Easy LintCode Hash
837 Palindromic-Substrings C++ O(n2) O(1) Easy LintCode
891 Valid Palindrome II C++ O(n) O(1) Medium NetEase,
Facebook
914 Flip Game C++ O(n) O(1) Easy Google
916 Palindrome Permutation C++ O(n) O(1) Easy Google HashMap
927 Reverse Words in a String ii C++ O(n) O(1) Medium LeetCode
936 Capitalizes The First Letter C++ O(n) O(1) Easy LintCode
1086 Repeated String Match C++ O(n) O(1) Easy Google KMP
1011 Number of Lines to Write String C++ O(n) O(1) Easy LintCode
1013 Unique Morse Code Words C++ O(n) O(n) Easy LintCode HashTable
1028 Rotated Digits C++ O(n) O(1) Easy LintCode
1056 Find Smallest Letter
Greater Than Target
C++ O(n) O(1) Easy LinkedIn
1079 Count Binary Substring C++ O(n) O(1) Easy Helix
1104 Judge Route Circle C++ O(n) O(1) Easy Google
1173 Reverse Words in A String III C++ O(n) O(1) Easy Zappos
1178 Student Attendance Record I C++ O(n) O(1) Easy Google
1193 Detect Capital C++ O(n) O(1) Easy Google
1204 Keyboard Row C++ O(n) O(1) Easy Mathworks
1214 License Key Formatting C++ O(n) O(1) Easy Google
1227 Repeated Substring Pattern C++ O(n) O(n) Easy Google,
Amazon
1243 Number of Segments in A String C++ O(n) O(1) Easy LintCode
1283 Reverse String C++ O(n) O(1) Easy LintCode
1394 Goat Latin C++ O(n) O(n) Easy Facebook
1510 Buddy Strings C++ O(n) O(1) Easy Google
1535 To Lower Case C++ O(n) O(1) Easy LintCode
1781 Reverse ASCII Encoded Strings C++ O(n) O(n) Easy Twitter

System Design

PID# Title Source Time Space Level Tag Note
499 Word Count Map Reduce C++ O(n) O(n) Easy LintCode Map-Reduce
501 Design Twitter(Mini Twitter) C++ O(klogu) O(t+f) Medium Twitter HashMap
504 Inverted Index Map Reduce C++ O(n) O(n) Medium LintCode Map-Reduce
537 N Gram Map Reduce C++ O(n) O(n) Medium LintCode Map-Reduce
607 Two Sum III Data Structure Design C++ O(n) O(n) Easy LinkedIn HashMap
660 Read N Charaters Given Read4 II
Call Multiple Times
C++ O(n) O(4) Medium

Tree

PID# Title Source Time Space Level Tag Note
7 Serialize and Deserialize Binary Tree C++ O(n) O(h) Medium Queue
85 Insert Node in a Binary Search Tree C++ O(h) O(1) Easy
88 Lowest Common Ancestor C++ O(n) O(h) Medium EPI Deque
175 Invert Binary Tree C++ O(n) O(h) Easy LeetCode DFS
242 Convert Binary Tree to
Linked Lists by Depth
C++ O(n) O(h) Easy LintCode BFS
442 Implement Trie Prefix Tree C++ O(n) O(n) Medium LeetCode Trie Tree
474 Lowest Common Ancestor II C++ O(n) O(h) Easy Stack
578 Lowest Common Ancestor III C++ O(n) O(h) Medium Deque
595 Binary Tree Longest
Consecutive Sequence
C++ O(n) O(1) Easy Google,
NetEase
596 Minimum Subtree C++ O(n) O(h) Easy DFS
597 Subtree with Maximum Average C++ O(n) O(h) Easy DFS
614 Binary Tree Longest
Consecutive Sequence II
C++ O(n) O(1) Easy Google
628 Maximum Subtree C++ O(n) O(h) Easy DFS
632 Binary Tree Maximum Node C++ O(n) O(1) Naive DFS
649 Binary Tree Upside Down C++ O(n) O(1) Medium LinkedIn
651 Binary Tree Vertical Order
Traversal
C++ O(n) O(n) Medium Google,
Facebook
Map
726 Check Full Binary Tree C++ O(n) O(1) Medium Amazon
921 Count Univalue Subtrees C++ O(n) O(1) Medium Postorder
1003 Binary Tree Pruning C++ O(n) O(1) Easy Hulu DFS
1085 Longest Univalue Path C++ O(n) O(1) Easy Google DFS
1094 Second Minimum Node in A
Binary Tree
C++ O(n) O(1) Easy LinkedIn DFS
1106 Maximum Binary Tree C++ O(nlogn) O(n) Easy Microsoft
1115 Average of Levels in
Binary Tree
C++ O(n) O(n) Easy Facebook Queue
1126 Merge Two Binary Trees C++ O(n) O(1) Easy Amazon
1137 Construct String from
Binary Tree
C++ O(n) O(n) Easy Amazon
1165 Subtree of Another Tree C++ O(n) O(n) Easy eBay,
Facebook
1172 Binary Tree Tilt C++ O(n) O(1) Easy Indeed Postorder
1181 Diameter of Binary Tree C++ O(n) O(1) Easy Google,
Facebook
Postorder
1198 Most Frequent Subtree Sum C++ O(n) O(n) Medium Amazon HashMap
1254 Sum of Left Leaves C++ O(n) O(1) Easy Facebook postorder
1360 Symmetric Tree C++ O(n) O(1) Easy LinkedIn,
Microsoft
postorder

空文件

简介

Yet another AC code for LintCode (598AC/1211ALL) 展开 收起
C++
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/eudiwffe/lintcode.git
git@gitee.com:eudiwffe/lintcode.git
eudiwffe
lintcode
lintcode
master

搜索帮助