Leetcode刷题指南和top100题目

原文链接:https://blog.csdn.net/qq_39521554/article/details/79160815
参考博文:https://blog.csdn.net/mmc2015/article/details/87200435

一、刷题方法

方法一:按照题目出现频率刷题

顺序参考文章最后的部分


方法二:标签法
按照网站给大家排列的不同tags,起到模块化的复习和学习作用。举个例子:比如复习链表的内容,就选Linked List这部分的23个题目。刷完之后可以再总结一下常用的方法和数据结构与构造方式。请不要为了刷题而刷题,一定是为了弥补一部分的知识去做。

方法三:随机法
随心所欲的选择难度与刷题顺序,哪个顺眼做哪个。本方法只适合业余编程,不从事本行业的同学以及大神级人物


方法四:必杀法
leetcode是有公司题库的,一句话:面哪家,刷哪家

 

方法五:顺序法
建议未刷过题的新人按着顺序(AC)来。前 150 题覆盖了很多经典题目和知识点,指针法类如『3 sum』系列,动规类如『regex matching』,搜索类题目如『Sodoku Solver』。

基本熟悉知识点(图、树、堆、栈、链表、哈希表、记忆搜索、动态规划、指针法、并查集等)后,可以一类类标签强攻。Leetcode 右侧的标签系统虽然未必 100% 完整,但是大致分类做得还不错。

面试前的一个月可以只做『Hard』标签的题目,因为一般两遍之后对于大部分『Medium』难度以下的题目都是肌肉记忆了。多练习『Hard』类题目可以让自己的思路更开阔,因为很多题目使用的奇淫巧技让人惊讶,比如 Leetcode 精心设计连续题号的『84. Largest Rectangle in Histogram』、『85. Maximal Rectangle』。

 


二、刷题攻略
TIP 1:

对于大多数人来说,没有时间也没有必要把所有题目都做一遍(时间充裕可以随意)。

可以考虑序号为前250位的题目,因为那些全是经典与必考题。

TIP 2:

善用收藏夹,要养成『一道题第二次练习尚不能解就加入收藏夹』的习惯,且需要定期清空收藏夹:每道题不需提示下通过两次后才能移出收藏夹。

TIP 3:

可以按照下文的面试出题频率顺序来做,从频率最高的一批开始。 而且请尽量不使用IDE,直接在平台上写代码。 

面试前可以购买会员,按照公司的标签来练习,也可以结合白板练习。面试前如果时间紧迫,那么练习的优先级分别是:即将面试公司的题目、收藏夹里的旧题目、剩余的新题。

冲刺阶段的练习请尽量不要打开题型标签,给自己思考的空间。如果真的刷了三遍以上还没法达到理想目标,那么一定是学习方法出了问题,请多总结。

TIP 4:
写好代码先不要提交,人工检查一下代码,比如分号是否都有写,return有没少等。 人工检查完后使用“Custom Testcase”功能自定义测试用例,注意检查边界,然后“Run Code”,这步可以发现蛮多问题的。  等RunCode通过后,再去提交。

 

 

————

Top 100个题目:https://leetcode.com/problemset/top-100-liked-questions/


  # Title Solution Acceptance Difficulty Frequency  
  1

Two Sum    

  40.2% Easy  
  2

Add Two Numbers    

  30.4% Medium  
  3

Longest Substring Without Repeating Characters    

  26.1% Medium  
  4

Median of Two Sorted Arrays    

  25.3% Hard  
  5

Longest Palindromic Substring    

  26.4% Medium  
  10

Regular Expression Matching    

  24.9% Hard  
  11

Container With Most Water    

  42.1% Medium  
  15

3Sum    

  23.2% Medium  
  17

Letter Combinations of a Phone Number    

  40.1% Medium  
  19

Remove Nth Node From End of List    

  33.9% Medium  
  20

Valid Parentheses    

  35.7% Easy  
  21

Merge Two Sorted Lists    

  45.5% Easy  
  22

Generate Parentheses    

  52.8% Medium  
  23

Merge k Sorted Lists    

  32.6% Hard  
  31

Next Permutation    

  30.0% Medium  
  32

Longest Valid Parentheses    

  24.8% Hard  
  33

Search in Rotated Sorted Array    

  32.6% Medium  
  34

Find First and Last Position of Element in Sorted Array    

  32.8% Medium  
  39

Combination Sum    

  46.3% Medium  
  42

Trapping Rain Water    

  41.5% Hard  
  46

Permutations    

  53.0% Medium  
  48

Rotate Image    

  46.4% Medium  
  49

Group Anagrams    

  44.3% Medium  
  53

Maximum Subarray    

  42.6% Easy  
  55

Jump Game    

  31.1% Medium  
  56

Merge Intervals    

  34.6% Medium  
  62

Unique Paths    

  46.1% Medium  
  64

Minimum Path Sum    

  45.2% Medium  
  70

Climbing Stairs    

  43.2% Easy  
  72

Edit Distance    

  36.2% Hard  
  75

Sort Colors    

  41.1% Medium  
  76

Minimum Window Substring    

  29.6% Hard  
  78

Subsets    

  50.5% Medium  
  79

Word Search    

  30.2% Medium  
  84

Largest Rectangle in Histogram    

  30.1% Hard  
  85

Maximal Rectangle    

  32.2% Hard  
  94

Binary Tree Inorder Traversal    

  54.7% Medium  
  96

Unique Binary Search Trees    

  44.8% Medium  
  98

Validate Binary Search Tree    

  25.1% Medium  
  101

Symmetric Tree    

  42.5% Easy  
  102

Binary Tree Level Order Traversal    

  46.7% Medium  
  104

Maximum Depth of Binary Tree    

  58.9% Easy  
  105

Construct Binary Tree from Preorder and Inorder Traversal    

  39.1% Medium  
  114

Flatten Binary Tree to Linked List    

  40.8% Medium  
  121

Best Time to Buy and Sell Stock    

  46.0% Easy  
  124

Binary Tree Maximum Path Sum    

  29.1% Hard  
  128

Longest Consecutive Sequence    

  40.7% Hard  
  136

Single Number    

  58.7% Easy  
  139

Word Break    

  34.1% Medium  
  141

Linked List Cycle    

  35.5% Easy
  # Title Solution Acceptance Difficulty Frequency  
  142

Linked List Cycle II    

  30.7% Medium  
  146

LRU Cache    

  23.7% Hard  
  148

Sort List    

  33.6% Medium  
  152

Maximum Product Subarray    

  28.4% Medium  
  155

Min Stack    

  35.3% Easy  
  160

Intersection of Two Linked Lists    

  31.9% Easy  
  169

Majority Element    

  51.2% Easy  
  198

House Robber    

  40.7% Easy  
  200

Number of Islands    

  40.0% Medium  
  206

Reverse Linked List    

  52.3% Easy  
  207

Course Schedule    

  36.4% Medium  
  208

Implement Trie (Prefix Tree)    

  36.4% Medium  
  215

Kth Largest Element in an Array    

  45.5% Medium  
  221

Maximal Square    

  32.1% Medium  
  226

Invert Binary Tree    

  56.8% Easy  
  234

Palindrome Linked List    

  35.2% Easy  
  236

Lowest Common Ancestor of a Binary Tree    

  35.0% Medium  
  238

Product of Array Except Self    

  53.6% Medium  
  239

Sliding Window Maximum    

  36.8% Hard  
  240

Search a 2D Matrix II    

  40.1% Medium  
  253

Meeting Rooms II    

  41.9% Medium  
  279

Perfect Squares    

  40.4% Medium  
  283

Move Zeroes    

  53.4% Easy  
  287

Find the Duplicate Number    

  48.0% Medium  
  297

Serialize and Deserialize Binary Tree    

  39.0% Hard  
  300

Longest Increasing Subsequence    

  40.1% Medium  
  301

Remove Invalid Parentheses    

  38.2% Hard  
  309

Best Time to Buy and Sell Stock with Cooldown    

  43.4% Medium  
  312

Burst Balloons    

  46.0% Hard  
  322

Coin Change    

  28.8% Medium  
  337

House Robber III    

  47.1% Medium  
  338

Counting Bits    

  63.8% Medium  
  347

Top K Frequent Elements    

  53.1% Medium  
  394

Decode String    

  43.6% Medium  
  406

Queue Reconstruction by Height    

  58.7% Medium  
  416

Partition Equal Subset Sum    

  39.7% Medium  
  437

Path Sum III    

  41.8% Easy  
  438

Find All Anagrams in a String    

  36.1% Easy  
  448

Find All Numbers Disappeared in an Array    

  52.6% Easy  
  461

Hamming Distance    

  70.0% Easy  
  494

Target Sum    

  44.8% Medium  
  538

Convert BST to Greater Tree    

  49.8% Easy  
  543

Diameter of Binary Tree    

  46.1% Easy  
  560

Subarray Sum Equals K    

  41.5% Medium  
  572

Subtree of Another Tree    

  41.1% Easy  
  581

Shortest Unsorted Continuous Subarray    

  29.6% Easy  
  617

Merge Two Binary Trees    

  69.0% Easy  
  621

Task Scheduler    

  44.1% Medium  
  647

Palindromic Substrings    

  55.5% Medium  
  771

Jewels and Stones    

  82.6% Easy

 

 

 

 

出现频度为5: 
1. Leet Code OJ 1. Two Sum [Difficulty: Easy] 
2. Leet Code OJ 8. String to Integer (atoi) [Difficulty: Easy] 
3. Leet Code OJ 15. 3Sum [Difficulty: Medium] 
4. Leet Code OJ 20. Valid Parentheses [Difficulty: Easy] 
5. Leet Code OJ 21. Merge Two Sorted Lists [Difficulty: Easy] 
6. Leet Code OJ 28. Implement strStr() [Difficulty: Easy] 
7. Leet Code OJ 56. Merge Intervals [Difficulty: Hard] 
8. Leet Code OJ 57. Insert Interval [Difficulty: Hard] 
9. Leet Code OJ 65. Valid Number [Difficulty: Hard] 
10. Leet Code OJ 70. Climbing Stairs [Difficulty: Easy] 
11. Leet Code OJ 73. Set Matrix Zeroes [Difficulty: Medium] 
12. Leet Code OJ 88. Merge Sorted Array [Difficulty: Easy] 
13. Leet Code OJ 98. Validate Binary Search Tree [Difficulty: Medium] 
14. Leet Code OJ 125. Valid Palindrome [Difficulty: Easy] 
15. Leet Code OJ 127. Word Ladder [Difficulty: Medium]

出现频度为4: 
1. Leet Code OJ 2. Add Two Numbers [Difficulty: Medium] 
2. Leet Code OJ 12. Integer to Roman 
3. Leet Code OJ 13. Roman to Integer 
4. Leet Code OJ 22. Generate Parentheses 
5. Leet Code OJ 23. Merge k Sorted Lists 
6. Leet Code OJ 24. Swap Nodes in Pairs 
7. Leet Code OJ 27. Remove Element [Difficulty: Easy] 
8. Leet Code OJ 46. Permutations 
9. Leet Code OJ 49. Anagrams 
10. Leet Code OJ 67. Add Binary 
11. Leet Code OJ 69. Sqrt(x) 
12. Leet Code OJ 77. Combinations 
13. Leet Code OJ 78. Subsets 
14. Leet Code OJ 79. Word Search 
15. Leet Code OJ 91. Decode Ways [Difficulty: Medium] 
16. Leet Code OJ 102. Binary Tree Level Order Traversal [Difficulty: Easy] 
17. Leet Code OJ 129. Sum Root to Leaf Numbers 
18. Leet Code OJ 131. Palindrome Partitioning

相关资源推荐


LeetCode和剑指offer题目大合集

关于LeetCode刷题及题目列表归纳

 

你可能感兴趣的:(Algorithm,Leetcode,leetcode,算法)