LeetCode刷题指南

作者: 云中布衣   分类:  编程之美    热度: (2093℃)   时间: 2016-12-21 9:22   标签: #leetcode    

时间真的过得很快,明年就要出去找工作了,最近忙着跟项目,基础编程能力很久没有训练了,这是比较可怕的。过硬的编程能力是取得面试机会的基础,而进行刷题训练是提高编程能力的必经之路。LeetCode作为业界公认的优秀刷题网站,自然是需要认真的刷一刷了。

按照目前的想法是,利用网上已经分好的类,按量分配,在回家之前一个多月的时间里用Python刷完第一遍,并做好总结笔记,同步在博客中。

整个leetcode题集,大致可以分成一下几类:

(01)Bit Manipulation

136 Single Number C++ Python O(n) O(1) Easy

137 Single Number II C++ Python O(n) O(1) Medium

190 Reverse Bits C++ Python O(1) O(1) Easy

191 Number of 1 Bits C++ Python O(1) O(1) Easy

201 Bitwise AND of Numbers Range C++ Python O(1) O(1) Medium

231 Power of Two C++ Python O(1) O(1) Easy

260 Single Number III C++ Python O(n) O(1) Medium

268 Missing Number C++ Python O(n) O(1) Medium

318 Maximum Product of Word Lengths C++ Python O(n) ~ O(n^2) O(n) Medium

342 Power of Four C++ Python O(1) O(1) Easy

371 Sum of Two Integers C++ Python O(1) O(1) Easy

389 Find the Difference C++ Python O(n) O(1) Easy

393 UTF-8 Validation C++ Python O(n) O(1) Medium

401 Binary Watch C++ Python O(1) O(1) Easy

411 Minimum Unique Word Abbreviation C++ Python O(2^n) O(n) Hard

421 Maximum XOR of Two Numbers in an Array C++ Python O(n) O(1) Medium

(02)Array

15 3 Sum C++ Python O(n^2) O(1) Medium

16 3 Sum Closest C++ Python O(n^2) O(1) Medium

18 4 Sum C++ Python O(n^3) O(1) Medium

26 Remove Duplicates from Sorted Array C++ Python O(n) O(1) Easy

27 Remove Element C++ Python O(n) O(1) Easy

31 Next Permutation C++ Python O(n) O(1) Medium

41 First Missing Positive C++ Python O(n) O(1) Hard

48 Rotate Image C++ Python O(n^2) O(1) Medium

54 Spiral Matrix C++ Python O(m * n) O(1) Medium

59 Spiral Matrix II C++ Python O(n^2) O(1) Medium

66 Plus One C++ Python O(n) O(1) Easy

73 Set Matrix Zeroes C++ Python O(m * n) O(1) Medium

80 Remove Duplicates from Sorted Array II C++ Python O(n) O(1) Medium

118 Pascal's Triangle C++ Python O(n^2) O(1) Easy

119 Pascal's Triangle II C++ Python O(n^2) O(1) Easy

121 Best Time to Buy and Sell Stock C++ Python O(n) O(1) Easy

128 Longest Consecutive Sequence C++ Python O(n) O(n) Hard

157 Read N Characters Given Read4 C++ Python O(n) O(1) Easy

158 Read N Characters Given Read4 II - Call multiple times C++ Python O(n) O(1) Hard

163 Missing Ranges C++ Python O(n) O(1) Medium

169 Majority Element C++ Python O(n) O(1) Easy

189 Rotate Array C++ Python O(n) O(1) Easy

209 Minimum Size Subarray Sum C++ Python O(n) O(1) Medium

215 Kth Largest Element in an Array C++ Python O(n) ~ O(n^2) O(1) Medium

228 Summary Ranges C++ Python O(n) O(1) Medium

229 Majority Element II C++ Python O(n) O(1) Medium

238 Product of Array Except Self C++ Python O(n) O(1) Medium

240 Search a 2D Matrix II C++ Python O(m + n) O(1) Medium

243 Shortest Word Distance C++ Python O(n) O(1) Easy

245 Shortest Word Distance III C++ Python O(n) O(1) Medium

251 Flatten 2D Vector C++ Python O(1) O(1) Medium

277 Find the Celebrity C++ Python O(n) O(1) Medium

289 Game of Life C++ Python O(m * n) O(1) Medium

293 Flip Game C++ Python O(n * (c+1)) O(1) Easy

296 Best Meeting Point C++ Python O(m * n) O(m + n) Hard

311 Sparse Matrix Multiplication C++ Python O(m * n * l) O(m * l) Medium

334 Increasing Triplet Subsequence C++ Python O(n) O(1) Medium

370 Range Addition C++ Python O(k + n) O(1) Medium

384 Shuffle an Array C++ Python O(n) O(n) Medium

396 Rotate Function C++ Python O(n) O(1) Easy

412 Fizz Buzz C++ Python O(n) O(1) Easy

414 Third Maximum Number C++ Python O(n) O(1) Easy

419 Battleships in a Board C++ Python O(m * n) O(1) Medium

422 Valid Word Square C++ Python O(m * n) O(1) Easy

442 Find All Duplicates in an Array C++ Python O(n) O(1) Medium

448 Find All Numbers Disappeared in an Array C++ Python O(n) O(1) Easy

(03)String

5 Longest Palindromic Substring C++ Python O(n) O(n) Medium

6 ZigZag Conversion C++ Python O(n) O(1) Easy

8 String to Integer (atoi) C++ Python O(n) O(1) Easy

14 Longest Common Prefix C++ Python O(n * k) O(1) Easy

28 Implement strStr() C++ Python O(n + k) O(k) Easy

38 Count and Say C++ Python O(n * 2^n) O(2^n) Easy

43 Multiply Strings C++ Python O(m * n) O(m + n) Medium

58 Length of Last Word C++ Python O(n) O(1) Easy

67 Add Binary C++ Python O(n) O(1) Easy

68 Text Justification C++ Python O(n) O(1) Hard

125 Valid Palindrome C++ Python O(n) O(1) Easy

151 Reverse Words in a String C++ Python O(n) O(1) Medium

161 One Edit Distance C++ Python O(m + n) O(1) Medium

165 Compare Version Numbers C++ Python O(n) O(1) Easy

186 Reverse Words in a String II C++ Python O(n) O(1) Medium

214 Shortest Palindrome C++ Python O(n) O(n) Hard

242 Valid Anagram C++ Python O(n) O(1) Easy

271 Encode and Decode Strings C++ Python O(n) O(1) Medium

273 Integer to English Words C++ Python O(logn) O(1) Hard

306 Addictive Number C++ Python O(n^3) O(n) Medium

383 Ransom Note C++ Python O(n) O(1) Easy

405 Convert a Number to Hexadecimal C++ Python O(n) O(1) Easy

408 Valid Word Abbreviation C++ Python O(n) O(1) Easy

415 Add Strings C++ Python O(n) O(1) Easy

420 Strong Password Checker C++ Python O(n) O(1) Hard

(04)Linked List

2 Add Two Numbers C++ Python O(n) O(1) Medium

21 Merge Two Sorted Lists C++ Python O(n) O(1) Easy

23 Merge k Sorted Lists C++ Python O(nlogk) O(1) Hard

24 Swap Nodes in Pairs C++ Python O(n) O(1) Easy

25 Reverse Nodes in k-Group C++ Python O(n) O(1) Hard

61 Rotate List C++ Python O(n) O(1) Medium

82 Remove Duplicates from Sorted List II C++ Python O(n) O(1) Medium

83 Remove Duplicates from Sorted List C++ Python O(n) O(1) Easy

92 Reverse Linked List II C++ Python O(n) O(1) Medium

138 Copy List with Random Pointer C++ Python O(n) O(1) Hard

160 Intersection of Two Linked Lists C++ Python O(m + n) O(1) Easy

203 Remove Linked List Elements C++ Python O(n) O(1) Easy

206 Reverse Linked List C++ Python O(n) O(1) Easy

234 Palindrome Linked List C++ Python O(n) O(1) Easy

237 Delete Node in a Linked List C++ Python O(1) O(1) Easy

328 Odd Even Linked List C++ Python O(n) O(1) Medium

369 Plus One Linked List C++ Python O(n) O(1) Medium

445 Add Two Numbers II C++ Python O(m + n) O(m + n) Medium

(05)Stack

20 Valid Parentheses C++ Python O(n) O(n) Easy

32 Longest Valid Parentheses C++ Python O(n) O(1) Hard

71 Simplify Path C++ Python O(n) O(n) Medium

84 Largest Rectangle in Histogram C++ Python O(n) O(n) Hard

85 Maximal Rectangle C++ Python O(m * n) O(n) Hard

101 Symmetric Tree C++ Python O(n) O(h) Easy

150 Evaluate Reverse Polish Notation C++ Python O(n) O(n) Medium

155 Min Stack C++ Python O(n) O(1) Easy

173 Binary Search Tree Iterator C++ Python O(1) O(h) Medium

224 Basic Calculator C++ Python O(n) O(n) Hard

227 Basic Calculator II C++ Python O(n) O(n) Medium

232 Implement Queue using Stacks C++ Python O(1), amortized O(n) Easy

255 Verify Preorder Sequence in Binary Search Tree C++ Python O(n) O(1) Medium

272 Closest Binary Search Tree Value II C++ Python O(h + k) O(h) Hard

331 Verify Preorder Serialization of a Binary Tree C++ Python O(n) O(1) Medium

341 Flatten Nested List Iterator C++ Python O(n) O(h) Medium

385 Mini Parser C++ Python O(n) O(h) Medium

394 Decode String C++ Python O(n) O(h) Medium

439 Ternary Expression Parser C++ Python O(n) O(1) Medium

(06)Queue

239 Sliding Window Maximum C++ Python O(n) O(k) Hard

281 Zigzag Iterator C++ Python O(n) O(k) Medium

346 Moving Average from Data Stream C++ Python O(1) O(w) Easy

(07)Heap

264 Ugly Number II C++ Python O(n) O(1) Medium

295 Find Median from Data Stream C++ Python O(nlogn) O(n) Hard

313 Super Ugly Number C++ Python O(n * k) O(n + k) Medium

358 Rearrange String k Distance Apart C++ Python O(n) O(n) Hard

373 Find K Pairs with Smallest Sums C++ Python O(k * log(min(n, m, k))) O(min(n, m, k)) Medium

378 Kth Smallest Element in a Sorted Matrix C++ Python O(k * log(min(n, m, k))) O(min(n, m, k)) Medium

407 Trapping Rain Water II C++ Python O(m * n * (logm + logn)) O(m * n) Hard

(08)Tree

94 Binary Tree Inorder Traversal C++ Python O(n) O(1) Medium

99 Recover Binary Search Tree C++ Python O(n) O(1) Hard

144 Binary Tree Preorder Traversal C++ Python O(n) O(1) Medium

145 Binary Tree Postorder Traversal C++ Python O(n) O(1) Hard

208 Implement Trie (Prefix Tree) C++ Python O(n) O(1) Medium

211 Add and Search Word - Data structure design C++ Python O(min(n, h)) O(min(n, h)) Medium

226 Invert Binary Tree C++ Python O(n) O(h), O(w) Easy

297 Serialize and Deserialize Binary Tree C++ Python O(n) O(h) Hard

307 Range Sum Query - Mutable C++ Python ctor: O(n), update: O(logn), query: O(logn) O(n) Medium

308 Range Sum Query 2D - Mutable C++ Python ctor: O(m * n), update: O(logm + logn), query: O(logm + logn) O(m * n) Hard

315 Count of Smaller Numbers After Self C++ Python O(nlogn) O(n) Hard

(09)Hash Table

1 Two Sum C++ Python O(n) O(n) Easy

3 Longest Substring Without Repeating Characters C++ Python O(n) O(1) Medium

30 Substring with Concatenation of All Words C++ Python O(m * n * k) O(n * k) Hard

36 Valid Sudoku C++ Python O(9^2) O(9) Easy

49 Group Anagrams C++ Python O(n * glogg) O(n) Medium

76 Minimum Window Substring C++ Python O(n) O(k) Hard

149 Max Points on a Line C++ Python O(n^2) O(n) Hard

159 Longest Substring with At Most Two Distinct Characters C++ Python O(n) O(1) Hard

170 Two Sum III - Data structure design C++ Python O(n) O(n) Easy

187 Repeated DNA Sequences Python O(n) O(n) Medium

202 Happy Number C++ Python O(k) O(k) Easy

204 Count Primes C++ Python O(n) O(n) Easy

205 Isomorphic Strings C++ Python O(n) O(1) Easy

217 Contains Duplicate C++ Python O(n) O(n) Easy

219 Contains Duplicate II C++ Python O(n) O(n) Easy

244 Shortest Word Distance II C++ Python ctor: O(n), lookup: O(a + b) O(n) Medium

246 Strobogrammatic Number C++ Python O(n) O(1) Easy

249 Group Shifted Strings C++ Python O(nlogn) O(n) Easy

266 Palindrome Permutation C++ Python O(n) O(1) Easy

288 Unique Word Abbreviation C++ Python ctor: O(n), lookup: O(1) O(k) Easy

290 Word Pattern C++ Python O(n) O(c) Easy

299 Bulls and Cows C++ Python O(n) O(1) Easy

305 Number of Islands II C++ Python O(k) O(k) Hard

314 Binary Tree Vertical Order Traversal C++ Python O(n) O(n) Medium

323 Number of Connected Components in an Undirected Graph C++ Python O(n) O(n) Medium

325 Maximum Size Subarray Sum Equals k C++ Python O(n) O(n) Medium

336 Palindrome Pairs C++ Python O(n * k^2) O(n * k) Hard

340 Longest Substring with At Most K Distinct Characters C++ Python O(n) O(1) Hard

356 Line Reflection C++ Python O(n) O(n) Medium

387 First Unique Character in a String C++ Python O(n) O(n) Easy

388 Longest Absolute File Path C++ Python O(n) O(d) Medium

409 Longest Palindrome C++ Python O(n) O(1) Easy

424 Longest Repeating Character Replacement C++ Python O(n) O(1) Medium

438 Find All Anagrams in a String C++ Python O(n) O(1) Easy

(10)Data Structure

146 LRU Cache C++ Python O(1) O(k) Hard

225 Implement Stack using Queues C++ Python push: O(n), pop: O(1), top: O(1) O(n) Easy

(11)Math

7 Reverse Integer C++ Python O(1) O(1) Easy

9 Palindrome Number C++ Python O(1) O(1) Easy

12 Integer to Roman C++ Python O(n) O(1) Medium

13 Roman to Integer C++ Python O(n) O(1) Easy

29 Divide Two Integers C++ Python O(1) O(1) Medium

50 Pow(x, n) C++ Python O(1) O(1) Medium

60 Permutation Sequence C++ Python O(n^2) O(n) Medium

65 Valid Number C++ Python O(n) O(1) Hard

89 Gray Code C++ Python O(2^n) O(1) Medium

166 Fraction to Recurring Decimal C++ Python O(logn) O(1) Medium

168 Excel Sheet Column Title C++ Python O(logn) O(1) Easy

171 Excel Sheet Column Number C++ Python O(n) O(1) Easy

172 Factorial Trailing Zeroes C++ Python O(1) O(1) Easy

223 Rectangle Area C++ Python O(1) O(1) Easy

233 Number of Digit One C++ Python O(1) O(1) Hard

248 Strobogrammatic Number III C++ Python O(5^(n/2)) O(n) Hard

258 Add Digits C++ Python O(1) O(1) Easy

263 Ugly Number C++ Python O(1) O(1) Easy

292 Nim Game C++ Python O(1) O(1) Easy

319 Bulb Switcher C++ Python O(1) O(1) Medium

326 Power of Three C++ Python O(1) O(1) Easy

335 Self Crossing C++ Python O(n) O(1) Hard

338 Counting Bits C++ Python O(n) O(n) Medium

343 Integer Break C++ Python O(logn) O(1) Medium

365 Water and Jug Problem C++ Python O(logn) O(1) Medium

372 Super Pow C++ Python O(n) O(1) Medium

382 Linked List Random Node C++ Python O(n) O(1) Medium

386 Lexicographical Numbers C++ Python O(n) O(1) Medium

390 Elimination Game C++ Python O(logn) O(1) Medium

391 Perfect Rectangle C++ Python O(n) O(n) Hard

398 Random Pick Index C++ Python O(n) O(1) Medium

400 Nth Digit C++ Python O(logn) O(1) Easy

413 Arithmetic Slices C++ Python O(n) O(1) Medium

423 Reconstruct Original Digits from English C++ Python O(n) O(1) Medium

441 Arranging Coins C++ Python O(nlogn) O(1) Easy

(12)Two Pointers

19 Remove Nth Node From End of List C++ Python O(n) O(1) Easy

86 Partition List C++ Python O(n) O(1) Medium

141 Linked List Cycle C++ Python O(n) O(1) Easy

142 Linked List Cycle II C++ Python O(n) O(1) Medium

143 Reorder List C++ Python O(n) O(1) Medium

167 Two Sum II - Input array is sorted C++ Python O(n) O(1) Medium

259 3Sum Smaller C++ Python O(n^2) O(1) Medium

283 Move Zeroes C++ Python O(n) O(1) Easy

287 Find the Duplicate Number C++ Python O(n) O(1) Hard

344 Reverse String C++ Python O(n) O(1) Easy

345 Reverse Vowels of a String C++ Python O(n) O(1) Easy

349 Intersection of Two Arrays C++ Python O(m + n) O(min(m, n)) Easy

350 Intersection of Two Arrays II C++ Python O(m + n) O(1) Easy

360 Sort Transformed Array C++ Python O(n) O(1) Medium

(13)Sort

56 Merge Intervals C++ Python O(nlogn) O(1) Hard

57 Insert Interval C++ Python O(n) O(1) Hard

75 Sort Colors C++ Python O(n) O(1) Medium

88 Merge Sorted Array C++ Python O(n) O(1) Easy

147 Insertion Sort List C++ Python O(n^2) O(1) Medium

148 Sort List C++ Python O(nlogn) O(logn) Medium

164 Maximum Gap C++ Python O(n) O(n) Hard

179 Largest Number C++ Python O(nlogn) O(1) Medium

218 The Skyline Problem C++ Python O(nlogn) O(n) Hard

252 Meeting Rooms C++ Python O(nlogn) O(n) Easy

253 Meeting Rooms II C++ Python O(nlogn) O(n) Medium

274 H-Index C++ Python O(n) O(n) Medium

280 Wiggle Sort C++ Python O(n) O(1) Medium

324 Wiggle Sort II C++ Python O(n) on average O(1) Medium

347 Top K Frequent Elements C++ Python O(n) on average O(n) Medium

406 Queue Reconstruction by Height C++ Python O(n * sqrt(n)) O(n) Medium

451 Sort Characters By Frequency C++ Python O(n) O(n) Medium

(14)Recursion

95 Unique Binary Search Trees II C++ Python O(4^n / n^(3/2) O(4^n / n^(3/2) Medium

98 Validate Binary Search Tree C++ Python O(n) O(1) Medium

100 Same Tree C+ Python O(n) O(h) Easy

104 Maximum Depth of Binary Tree C++ Python O(n) O(h) Easy

105 Construct Binary Tree from Preorder and Inorder Traversal C++ Python O(n) O(n) Medium

106 Construct Binary Tree from Inorder and Postorder Traversal C++ Python O(n) O(n) Medium

108 Convert Sorted Array to Binary Search Tree C++ Python O(n) O(logn) Medium

109 Convert Sorted List to Binary Search Tree C++ Python O(n) O(logn) Medium

110 Balanced Binary Tree Python O(n) O(h) Easy

111 Minimum Depth of Binary Tree Python O(n) O(h) Easy

114 Flatten Binary Tree to Linked List Python O(n) O(h) Medium

116 Populating Next Right Pointers in Each Node Python O(n) O(1) Medium

124 Binary Tree Maximum Path Sum Python O(n) O(h) Hard

129 Sum Root to Leaf Numbers Python O(n) O(h) Medium

156 Binary Tree Upside Down Python O(n) O(1) Medium

241 Different Ways to Add Parentheses C++ Python O(n * 4^n / n^(3/2)) O(n * 4^n / n^(3/2)) Medium

298 Binary Tree Longest Consecutive Sequence C++ Python O(n) O(h) Medium

327 Count of Range Sum C++ Python O(nlogn) O(n) Hard

333 Largest BST Subtree C++ Python O(n) O(h) Medium

337 House Robber III C++ Python O(n) O(h) Medium

395 Longest Substring with At Least K Repeating Characters C++ Python O(n) O(1) Medium

404 Sum of Left Leaves C++ Python O(n) O(h) Easy

437 Path Sum III C++ Python O(n^2) O(h) Easy

(15)Binary Search

4 Median of Two Sorted Arrays C++ Python O(log(min(m, n))) O(1) Hard

33 Search in Rotated Sorted Array C++ Python O(logn) O(1) Hard

34 Search for a Range C++ Python O(logn) O(1) Medium

35 Search Insert Position C++ Python O(logn) O(1) Medium

69 Sqrt(x) C++ Python O(logn) O(1) Medium

74 Search a 2D Matrix C++ Python O(logm + logn) O(1) Medium

81 Search in Rotated Sorted Array II C++ Python O(logn) O(1) Medium

153 Find Minimum in Rotated Sorted Array C++ Python O(logn) O(1) Medium

154 Find Minimum in Rotated Sorted Array II C++ Python O(logn) ~ O(n) O(1) Hard

162 Find Peak Element C++ Python O(logn) O(1) Medium

222 Count Complete Tree Nodes C++ Python O((logn)^2) O(1) Medium

275 H-Index II C++ Python O(logn) O(1) Medium

278 First Bad Version C++ Python O(logn) O(1) Easy

300 Longest Increasing Subsequence C++ Python O(nlogn) O(n) Medium

302 Smallest Rectangle Enclosing Black Pixels C++ Python O(nlogn) O(1) Hard

354 Russian Doll Envelopes C++ Python O(nlogn) O(1) Hard

363 Max Sum of Rectangle No Larger Than K C++ Python O(min(m, n)^2 * max(m, n) * logn(max(m, n))) O(max(m, n)) Hard

367 Valid Perfect Square C++ Python O(logn) O(1) Medium

374 Guess Number Higher or Lower C++ Python O(logn) O(1) Easy

410 Split Array Largest Sum C++ Python O(nlogs) O(1) Hard

436 Find Right Interval C++ Python O(nlogn) O(n) Medium

(16)Binary Search Tree

220 Contains Duplicate III C++ Python O(nlogk) O(k) Medium

230 Kth Smallest Element in a BST C++ Python O(max(h, k)) O(min(h, k)) Medium

235 Lowest Common Ancestor of a Binary Search Tree C++ Python O(h) O(1) Easy

270 Closest Binary Search Tree Value C++ Python O(h) O(1) Easy

285 Inorder Successor in BST C++ Python O(h) O(1) Medium

352 Data Stream as Disjoint Intervals C++ Python O(logn) O(n) Hard

449 Serialize and Deserialize BST C++ Python O(n) O(h) Medium

450 Delete Node in a BST C++ Python O(h) O(h) Medium

(17)Breadth-First Search

102 Binary Tree Level Order Traversal C++ Python O(n) O(n) Easy

107 Binary Tree Level Order Traversal II Python O(n) O(n) Easy

103 Binary Tree Zigzag Level Order Traversal Python O(n) O(n) Medium

117 Populating Next Right Pointers in Each Node II Python O(n) O(1) Hard

127 Word Ladder Python O(n * d) O(d) Medium

130 Surrounded Regions C++ Python O(m * n) O(m + n) Medium

133 Clone Graph Python O(n) O(n) Medium

207 Course Schedule Python O(|V| + |E|) O(|E|) Medium

210 Course Schedule II Python O(|V| + |E|) O(|E|) Medium

261 Graph Valid Tree C++ Python O(|V| + |E|) O(|V| + |E|) Medium

269 Alien Dictionary C++ Python O(n) O(1) Hard

286 Walls and Gates C++ Python O(m * n) O(g) Medium

310 Minimum Height Trees C++ Python O(n) O(n) Medium

317 Shortest Distance from All Buildings C++ Python O(k * m * n) O(m * n) Hard

433 Minimum Genetic Mutation C++ Python O(n * b) O(b) Medium

444 Sequence Reconstruction C++ Python O(n * s) O(n) Medium

(18)Depth-First Search

112 Path Sum Python O(n) O(h) Easy

113 Path Sum II Python O(n) O(h) Medium

199 Binary Tree Right Side View Python O(n) O(h) Medium

200 Number of Islands Python O(m * n) O(m * n) Medium

236 Lowest Common Ancestor of a Binary Tree C++ Python O(n) O(h) Medium

247 Strobogrammatic Number II C++ Python O(n^2 * 5^(n/2)) O(n) Medium

250 Count Univalue Subtrees C++ Python O(n) O(h) Medium

257 Binary Tree Paths C++ Python O(n * h) O(h) Easy

282 Expression Add Operators C++ Python O(4^n) O(n) Hard

301 Remove Invalid Parentheses C++ Python O(C(n, c)) O(c) Hard

329 Longest Increasing Path in a Matrix C++ Python O(m * n) O(m * n) Hard

332 Reconstruct Itinerary C++ Python O(t! / (n1! * n2! * ... nk!)) O(t) Medium

339 Nested List Weight Sum C++ Python O(n) O(h) Easy

364 Nested List Weight Sum II C++ Python O(n) O(h) Medium

366 Find Leaves of Binary Tree C++ Python O(n) O(h) Medium

399 Evaluate Division C++ Python O(q * |V|!) O(e) Medium

417 Pacific Atlantic Water Flow C++ Python O(m * n) O(m * n) Medium

440 K-th Smallest in Lexicographical Order C++ Python O(logn) O(logn) Hard

(19)Backtracking

17 Letter Combinations of a Phone Number Python O(n * 4^n) O(n) Medium

22 Generate Parentheses Python O(4^n / n^(3/2)) O(n) Medium

37 Sudoku Solver Python O((9!)^9) O(1) Hard

39 Combination Sum Python O(k * n^k) O(k) Medium

40 Combination Sum II Python O(k * C(n, k)) O(k) Medium

46 Permutations Python O(n * n!) O(n) Medium

47 Permutations II Python O(n * n!) O(n) Medium

51 N-Queens Python O(n!) O(n) Hard

52 N-Queens-II Python O(n!) O(n) Hard

77 Combinations Python O(n!) O(n) Medium

79 Word Search Python O(m * n * l) O(l) Medium

93 Restore IP Addresses Python O(1) O(1) Medium

78 Subsets C++ Python O(n * 2^n) O(1) Medium

90 Subsets II C++ Python O(n * 2^n) O(1) Medium

126 Word Ladder II Python O(n * d) O(d) Hard

131 Palindrome Partitioning Python O(n^2) ~ O(2^n) O(n^2) Medium

140 Word Break II C++ Python O(n * l^2 + n * r) O(n^2) Hard

212 Word Search II C++ Python O(m * n * l) O(l) Hard

216 Combination Sum III C++ Python O(k * C(n, k)) O(k) Medium

254 Factor Combinations C++ Python O(nlogn) O(logn) Medium

267 Palindrome Permutation II C++ Python O(n * n!) O(n) Medium

291 Word Pattern II C++ Python O(n * C(n - 1, c - 1)) O(n + c) Hard

294 Flip Game II C++ Python O(n + c^2) O(c) Medium

320 Generalized Abbreviation C++ Python O(n * 2^n) O(n) Medium

425 Word Squares C++ Python O(n^2 * n!) O(n^2) Hard

(20)Dynamic Programming

10 Regular Expression Matching Python O(m * n) O(n) Hard

53 Maximum Subarray Python O(n) O(1) Medium

62 Unique Paths Python O(m * n) O(m + n) Medium

63 Unique Paths II Python O(m * n) O(m + n) Medium

64 Minimum Path Sum Python O(m * n) O(m + n) Medium

70 Climbing Stairs Python O(n) O(1) Easy

72 Edit Distance Python O(m * n) O(m + n) Hard

87 Scramble String Python O(n^4) O(n^3) Hard

91 Decode Ways C++ Python O(n) O(1) Medium

96 Unique Binary Search Trees Python O(n) O(1) Medium

97 Interleaving String Python O(m * n) O(m + n) Hard

115 Distinct Subsequences Python O(n^2) O(n) Hard

120 Triangle Python O(m * n) O(n) Medium

123 Best Time to Buy and Sell Stock III Python O(n) O(1) Hard

132 Palindrome Partitioning II Python O(n^2) O(n^2) Hard

139 Word Break C++ Python O(n * l^2) O(n) Medium

152 Maximum Product Subarray Python O(n) O(1) Medium

174 Dungeon Game Python O(m * n) O(m + n) Hard

188 Best Time to Buy and Sell Stock IV Python O(k * n) O(k) Hard

198 House Robber Python O(n) O(1) Easy

213 House Robber II C++ Python O(n) O(1) Medium

221 Maximal Square C++ Python O(n^2) O(n) Medium

256 Paint House C++ Python O(n) O(1) Medium

265 Paint House II C++ Python O(n * k) O(k) Hard

276 Paint Fence C++ Python O(n) O(1) Easy

279 Perfect Squares C++ Python O(n * sqrt(n)) O(n) Medium

303 Range Sum Query - Immutable C++ Python ctor: O(n), lookup: O(1) O(n) Easy

304 Range Sum Query 2D - Immutable C++ Python ctor: O(m * n), lookup: O(1) O(m * n) Medium

309 Best Time to Buy and Sell Stock with Cooldown C++ Python O(n) O(1) Medium

312 Burst Balloons C++ Python O(n^3) O(n^2) Hard

322 Coin Change C++ Python O(n * k) O(k) Medium

351 Android Unlock Patterns C++ Python O(9^2 * 2^9) O(9 * 2^9) Medium

357 Count Numbers with Unique Digits C++ Python O(n) O(1) Medium

361 Bomb Enemy C++ Python O(m * n) O(m * n) Medium

368 Largest Divisible Subset C++ Python O(n^2) O(n) Medium

375 Guess Number Higher or Lower II C++ Python O(n^2) O(n^2) Medium

377 Combination Sum IV C++ Python O(nlogn + n * t) O(t) Medium

403 Frog Jump C++ Python O(n) O(n) ~ O(n^2) Hard

416 Partition Equal Subset Sum C++ Python O(n * s) O(s) Medium

418 Sentence Screen Fitting C++ Python O(r + n * c) O(n) Medium

(21)Greedy

11 Container With Most Water C++ Python O(n) O(1) Medium

42 Trapping Rain Water C++ Python O(n) O(1) Hard

44 Wildcard Matching Python O(m + n) O(1) Hard

45 Jump Game II Python O(n) O(1) Hard

55 Jump Game Python O(n) O(1) Medium

122 Best Time to Buy and Sell Stock II Python O(n) O(1) Medium

134 Gas Station Python O(n) O(1) Medium

135 Candy C++ Python O(n) O(n) Hard

316 Remove Duplicate Letters C++ Python O(n) O(k) Hard

321 Create Maximum Number C++ Python O(k * (m + n + k)) ~ O(k * (m + n + k^2)) O(m + n + k^2) Hard

330 Patching Array C++ Python O(s + logn) O(1) Hard

376 Wiggle Subsequence C++ Python O(n) O(1) Medium

392 Is Subsequence C++ Python O(n) O(1) Medium

397 Integer Replacement C++ Python O(n) O(1) Medium

402 Remove K Digits C++ Python O(n) O(n) Medium

435 Non-overlapping Intervals C++ Python O(nlogn) O(1) Medium

以上是对,leetcode大部分开放问题的一个大概的分类,大致分成21类,而我的刷题计划就从这21类问题,逐个入手。

以上分类整理自GitHub库:https://github.com/kamyu104/LeetCode

<完>

56.8K

发表评论:

© 云中布衣 2015 | Driven by EMLOG  | SiteMap | RunTime: 10.37ms&RSS  | MORE  |   | TOP

文章数量【258】 评论数量【238】 稳定运行【1210天】

Visitor IP Address【54.82.73.21】

Email:ieeflsyu#outlook.com