leetcode

目前所完成的leetcode题目
还有部分lintcode题目

Tips

  • 加速输入
int x=[](){
    std::ios::sync_with_stdio(false);           //解除与C输入输出的兼容,解绑后请不要混用两者
    cin.tie(NULL);          //暂时不太理解
    return 0;
}();

summary

  • 一些总结性md文件

完成情况(按难度分类)

  • *符号表示有leetcode上的代码
  • leetcode上的代码大多数都是用时最少的代码,或者是算法比较新奇的。

easy 完成情况

  • 561 Array Partition I*

66.3%

  • 766 Toeplitz Matrix

57.7%

  • 566 Reshape the Matrix*

57.7%

  • 485 Max Consecutive Ones*

53.7%

  • 695 Max Area of Island* (DFS)

51.8%

  • 283 Move Zeroes*

51.5%

  • 448 Find All Numbers Disappeared in an Array*

51.2%

  • 717 1-bit and 2-bit Characters*

49.5%

  • 122 Best Time to Buy and Sell Stock II*

47.8%

  • 169 Majority Element* (本题有错误)

47.9%

  • 167 Two Sum II - Input array is sorted*

47.3%

  • 217 Contains Duplicate* (类似快排和类似冒泡)

47.0%

  • 697 Degree of an Array*

46.7%

  • 661 Image Smoother

46.2%

  • 665 Non-decreasing Array

20.3%

  • 771 Jewels and Stones*

82.1%

  • 290 Word Pattern*

33.9%

  • 234 Palindrome Linked List*

34.2%

  • 434 Number of Segments in a String

36.5%

  • 198 House Robber

40.4%

  • 303 Range Sum Query - Immutable* (没写出来)

34.1%

  • 121 Best Time to Buy and Sell Stock*

44.3%

  • 674 Longest Continuous Increasing Subsequence

42.9%

  • lintcode 397 Longest Continuous Increasing Subsequence

31%

  • 1 Two Sum

38.9%

  • 521 Longest Uncommon Subsequence I

55.7%

  • lintcode 128 Hash Function

21%

  • 28 Implement strStr()*

30.2%

  • 35 Search Insert Position

40.0%

  • 278 First Bad Version

27.5%

  • 852 Peak Index in a Mountain Array

67.1%

  • lintcode 39 Recover Rotated Sorted Array

29%

  • 189 Rotate Array

27.3%

  • 21 Merge Two Sorted Lists

43.7%

  • 112 Path Sum

36.1%

  • 437 Path Sum III

40.7%

  • 100 Same Tree

48.6%

  • 111 Minimum Depth of Binary Tree

34.3%

  • 110 Balanced Binary Tree

39.5%

  • 107 Binary Tree Level Order Traversal II

44.2%

  • 104 Maximum Depth of Binary Tree

57.5%

  • 257 Binary Tree Paths*

43.6%

  • lintcode 596 Minimum Subtree

37%

  • lintcode 597 Subtree with Maximum Average

27%

  • lintcode 474 Lowest Common Ancestor II

39%

  • 118 Pascal's Triangle

42.8%

  • 119 Pascal's Triangle II

40.5%

  • 53 Maximum Subarray

41.7%

  • 67 Add Binary

36.5%

  • 14 Longest Common Prefix

32.3%

  • 101 Symmetric Tree

42.8%

  • 232 Implement Queue using Stacks

42.2%

  • 38 Count and Say

40.0%

  • 13 Roman to Integer

52.0%

  • 7 Reverse Integer

25.2%

  • 9 Palindrome Number

42.7%

  • 20 Valid Parentheses

36.2%

  • 263 Ugly Number

40.5%

  • 66 Plus One

41.0%

  • 58 Length of Last Word

32.2%

medium 完成情况

  • 442 Find All Duplicates in an Array*

58.6%

  • 495 Teemo Attacking*

51.4%

  • 667 Beautiful Arrangement II* (没写出来,参考的网上思路写出来的)

51.4%

  • 238 Product of Array Except Self*

50.3%

  • 565 Array Nesting*

49.4%

  • 769 Max Chunks To Make Sorted*

47.9%

  • 216 Combination Sum III*

47.2%

  • 714 Best Time to Buy and Sell Stock with Transaction Fee*

45.4%

  • 78 Subsets*

44.8%

  • 287 Find the Duplicate Number*

44.3%

  • 62 Unique Paths*

42.9%

  • 90 Subsets II*

38.4%

  • 15 3Sum* (有难度)

21.8%

  • 54 Spriral Matrix*

27.3%

  • 59 Spiral Matrix II*

41.1%

  • 31 Next Permutation

29.1%

  • 209 Minimum Size Subarray Sum* (有难度)

32.6%

  • 236 Lowest Common Ancestor of a Binary Tree*

31.3%

  • 718 Maximum Length of Repeated Subarray* (dp)

42.2%

  • 289 Game of Life

38.9%

  • 523 Continuous Subarray Sum* (有难度)

23.4%

  • 152 Maximum Product Subarray* (也不算有难度,一开始想法太过复杂,没有总结出合适的简洁规律)

27.3%

  • 16 3Sum Closest* (没写出来简易算法,利用暴力解写出来的)

32.5%

  • 55 Jump Game* (有难度)

30.2%

  • 11 Container With Most Water

38.5%

  • 18 4Sum*

28.3%

  • 213 House Robber II

34.7%

  • 64 Minimum Path Sum*

42.8%

  • 63 Unique Paths II*

32.6%

  • 120 Triangle*

36.4%

  • 556 Next Greater Element III*

29.1%

  • 309 Best Time to Buy and Sell Stock with Cooldown*

42.7%

  • lintcode 515 Paint House

38%

  • 91 Decode Ways*

21.0%

  • 322 Coin Change*

27.3%

  • 300 Longest Increasing Subsequence*

39.3%

  • 673 Number of Longest Increasing Subsequence*

32.0%

  • lintcode 553 Bomb Enemy

34%

  • 338 Counting Bits*

62.9%

  • 337 House Robber III*

45.9%

  • 2 Add Two Numbers

29.2%

  • 3 Longest Substring Without Repeating Characters

28.0%

  • 279 Perfect Squares*

38.9%

  • 131 Palindrome Partitioning*

37.7%

  • lintcode 92 Backpack

27%

  • 516 Longest Palindromic Subsequence*

43.8%

  • lintcode 394 Coins in a Line

44%

  • lintcode 395 Coins in a Line II

34%

  • 486 Predict the Winner*

45.8%

  • 162 Find Peak Element*

39.9%

  • lintcode 77 Longest Common Subsequence

40%

  • 474 Ones and Zeroes*

38.7%

  • lintcode 91 Minimum Adjustment Cost

32%

  • 377 Combination Sum IV*

43.3%

  • lintcode 640 One Edit Distance

31%

  • lintcode 623 K Edit Distance(未完成)

31%

  • 221 Maximal Square*

31.4%

  • 29 Divide Two Integers(未完成)

15.7%

  • 74 Search a 2D Matrix*

34.4%

  • 34 Find First and Last Position of Element in Sorted Array*

32.2%

  • lintcode 447 Search in a Big Sorted Array

加锁题,答案参考网上

  • 153 Find Minimum in Rotated Sorted Array*

41.8%

  • lintcode 585 Maximum Number in Mountain Sequence

49%

  • 33 Search in Rotated Sorted Array*

32.2%

  • 658 Find K Closest Elements*

35.2%

  • 240 Search a 2D Matrix II

39.5%

  • 81 Search in Rotated Sorted Array II*

32.4%

  • 113 Path Sum II*

37.9%

  • 94 Binary Tree Inorder Traversal*

53.0%

  • 144 Binary Tree Preorder Traversal

48.9%

  • 102 Binary Tree Level Order Traversal

45.3%

  • 103 Binary Tree Zigzag Level Order Traversal

38.9%

  • lintcode 578 Lowest Common Ancestor III

27%

  • 98 Validate Binary Search Tree*

24.6%

  • lintcode 378 Convert Binary Search Tree to Doubly Linked List

32%

  • 114 Flatten Binary Tree to Linked List*

39.3%

  • 173 Binary Search Tree Iterator*

45.1%

  • lintcode 448 Inorder Successor in BST

36%

  • lintcode 11 Search Range in Binary Search Tree

38%

  • 701 Insert into a Binary Search Tree

67.8%

  • 450 Delete Node in a BST

38.1%

  • 449 Serialize and Deserialize BST

44.1%

  • lintcode 178 Graph Valid Tree

29%

  • 133 Clone Graph*

25.1%

  • lintcode 127 Topological Sorting

34%

  • 207 Course Schedule*

35.4%

  • 210 Course Schedule II*

32.2%

  • lintcode 605 Sequence Reconstruction

21%

  • 200 Number of Islands*

38.6%

  • lintcode 434 Number of Islands II(未完成)

20%

  • lintcode 611 Knight Shortest Path

26%

  • 147 Insertion Sort List

35.5%

  • 75 Sort Colors

40.4%

  • 215 Kth Largest Element in an Array

43.9%

  • 148 Sort List(未完成)

32.5%

  • 105 Construct Binary Tree from Preorder and Inorder Traversal*

39.6%

  • 19 Remove Nth Node From End of List

34.0%

  • 96 Unique Binary Search Trees

45.3%

  • 5 Longest Palindromic Substring

26.8%

  • 39 Combination Sum

47.5%

  • 40 Combination Sum II

40.8%

  • 77 Combinations

46.8%

  • 36 Valid Sudoku

42.4%

  • 8 String to Integer (atoi)

14.6%

  • 12 Integer to Roman

50.4%

  • 6 ZigZag Conversion

31.2%

  • 17 Letter Combinations of a Phone Number

41.0%

  • 24 Swap Nodes in Pairs

43.9%

  • 29 Divide Two Integers

16.1%

  • 264 Ugly Number II

36.0%

  • 313 Super Ugly Number*

40.9%

  • 46 Permutations

54.4%

  • 47 Permutations II

39.9%

  • 56 Merge Intervals*

35.4%

  • 71 Simplify Path*

28.5%

  • 22 Generate Parentheses*

55.6%

  • 48 Rotate Image*

49.3%

hard 完成情况

  • 768 Max Chunks To Make Sorted II*

43.1%

  • 214 Shortest Palindrome(未完成)

25.8%

  • 45 Jump Game II*

26.3%

  • 41 First Missing Positive*

26.7%

  • lintcode 516 Paint House II

29%

  • 123 Best Time to Buy and Sell Stock III*

31.6%

  • 188 Best Time to Buy and Sell Stock IV*

25.3%

  • 354 Russian Doll Envelopes*

32.8%

  • 132 Palindrome Partitioning II*

25.8%

  • lintcode 437 Copy Books*

31%

  • lintcode 396 Coins in a Line III

37%

  • 87 Scramble String*

30.4%

  • 312 Burst Balloons*

44.7%

  • 97 Interleaving String*

26.2%

  • 72 Edit Distance*

34.6%

  • 115 Distinct Subsequences*

33.4%

  • 10 Regular Expression Matching*

24.4%

  • 44 Wildcard Matching*

21.7%

  • lintcode 89 k Sum

27%

  • 403 Frog Jump*

33.9%

  • lintcode 594 strStr II

26%

  • lintcode 600 Smallest Rectangle Enclosing Black Pixels(未完成)

28%

  • 154 Find Minimum in Rotated Sorted Array II*

38.5%

  • 145 Binary Tree Postorder Traversal*

45.1%

  • 297 Serialize and Deserialize Binary Tree*

37.5%

  • lintcode 573 Build Post Office II

28%

  • 23 Merge k Sorted Lists*

33.8%

  • 329 Longest Increasing Path in a Matrix

39.7%

  • 32 Longest Valid Parentheses 26.0%