参考:https://blog.csdn.net/qq_39521554/article/details/79160815
二、刷题方法
方法一:按照题目出现频率刷题
顺序参考文章最后的部分
方法二:标签法
按照网站给大家排列的不同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 | 40.2% | Easy | ||||
2 | 30.4% | Medium | ||||
3 | 26.1% | Medium | ||||
4 | 25.3% | Hard | ||||
5 | 26.4% | Medium | ||||
10 | 24.9% | Hard | ||||
11 | 42.1% | Medium | ||||
15 | 23.2% | Medium | ||||
17 | 40.1% | Medium | ||||
19 | 33.9% | Medium | ||||
20 | 35.7% | Easy | ||||
21 | 45.5% | Easy | ||||
22 | 52.8% | Medium | ||||
23 | 32.6% | Hard | ||||
31 | 30.0% | Medium | ||||
32 | 24.8% | Hard | ||||
33 | 32.6% | Medium | ||||
34 | 32.8% | Medium | ||||
39 | 46.3% | Medium | ||||
42 | 41.5% | Hard | ||||
46 | 53.0% | Medium | ||||
48 | 46.4% | Medium | ||||
49 | 44.3% | Medium | ||||
53 | 42.6% | Easy | ||||
55 | 31.1% | Medium | ||||
56 | 34.6% | Medium | ||||
62 | 46.1% | Medium | ||||
64 | 45.2% | Medium | ||||
70 | 43.2% | Easy | ||||
72 | 36.2% | Hard | ||||
75 | 41.1% | Medium | ||||
76 | 29.6% | Hard | ||||
78 | 50.5% | Medium | ||||
79 | 30.2% | Medium | ||||
84 | 30.1% | Hard | ||||
85 | 32.2% | Hard | ||||
94 | 54.7% | Medium | ||||
96 | 44.8% | Medium | ||||
98 | 25.1% | Medium | ||||
101 | 42.5% | Easy | ||||
102 | 46.7% | Medium | ||||
104 | 58.9% | Easy | ||||
105 | 39.1% | Medium | ||||
114 | 40.8% | Medium | ||||
121 | 46.0% | Easy | ||||
124 | 29.1% | Hard | ||||
128 | 40.7% | Hard | ||||
136 | 58.7% | Easy | ||||
139 | 34.1% | Medium | ||||
141 | 35.5% | Easy |
# | Title | Solution | Acceptance | Difficulty | Frequency | |
---|---|---|---|---|---|---|
142 | 30.7% | Medium | ||||
146 | 23.7% | Hard | ||||
148 | 33.6% | Medium | ||||
152 | 28.4% | Medium | ||||
155 | 35.3% | Easy | ||||
160 | 31.9% | Easy | ||||
169 | 51.2% | Easy | ||||
198 | 40.7% | Easy | ||||
200 | 40.0% | Medium | ||||
206 | 52.3% | Easy | ||||
207 | 36.4% | Medium | ||||
208 | 36.4% | Medium | ||||
215 | 45.5% | Medium | ||||
221 | 32.1% | Medium | ||||
226 | 56.8% | Easy | ||||
234 | 35.2% | Easy | ||||
236 | 35.0% | Medium | ||||
238 | 53.6% | Medium | ||||
239 | 36.8% | Hard | ||||
240 | 40.1% | Medium | ||||
253 | 41.9% | Medium | ||||
279 | 40.4% | Medium | ||||
283 | 53.4% | Easy | ||||
287 | 48.0% | Medium | ||||
297 | 39.0% | Hard | ||||
300 | 40.1% | Medium | ||||
301 | 38.2% | Hard | ||||
309 | 43.4% | Medium | ||||
312 | 46.0% | Hard | ||||
322 | 28.8% | Medium | ||||
337 | 47.1% | Medium | ||||
338 | 63.8% | Medium | ||||
347 | 53.1% | Medium | ||||
394 | 43.6% | Medium | ||||
406 | 58.7% | Medium | ||||
416 | 39.7% | Medium | ||||
437 | 41.8% | Easy | ||||
438 | 36.1% | Easy | ||||
448 | 52.6% | Easy | ||||
461 | 70.0% | Easy | ||||
494 | 44.8% | Medium | ||||
538 | 49.8% | Easy | ||||
543 | 46.1% | Easy | ||||
560 | 41.5% | Medium | ||||
572 | 41.1% | Easy | ||||
581 | 29.6% | Easy | ||||
617 | 69.0% | Easy | ||||
621 | 44.1% | Medium | ||||
647 | 55.5% | Medium | ||||
771 | 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