算法面試過程中,題目類型多,數量大。大家都不可避免的會在LeetCode上進行訓練。但問題是,題目雜,而且已經超過1300道題。
全部刷完且掌握,不是一件容易的事情。那我們應該怎么辦呢?找規律,總結才是制勝法寶。
下面我們就來看看 Grokking the Coding Interview: Patterns for Coding Questions的分類及每個類型的經典題目:
1. Pattern: Sliding window,滑動窗口類型
經典題目:
Maximum Sum Subarray of Size K (easy)
Smallest Subarray with a given sum (easy)
Longest Substring with K Distinct Characters (medium)
Fruits into Baskets (medium)
No-repeat Substring (hard)
Longest Substring with Same Letters after Replacement (hard)
Longest Subarray with Ones after Replacement (hard)
2. Pattern: two points, 雙指針類型
經典題目:
Pair with Target Sum (easy)
Remove Duplicates (easy)
Squaring a Sorted Array (easy)
Triplet Sum to Zero (medium)
Triplet Sum Close to Target (medium)
Triplets with Smaller Sum (medium)
Subarrays with Product Less than a Target (medium)
Dutch National Flag Problem (medium)
3. Pattern: Fast & Slow pointers, 快慢指針類型
經典題目:
LinkedList Cycle (easy)
Start of LinkedList Cycle (medium)
Happy Number (medium)
Middle of the LinkedList (easy)
4. Pattern: Merge Intervals,區間合並類型
經典題目:
Merge Intervals (medium)
Insert Interval (medium)
Intervals Intersection (medium)
Conflicting Appointments (medium)
5. Pattern: Cyclic Sort,循環排序
經典題目:
Cyclic Sort (easy)
Find the Missing Number (easy)
Find all Missing Numbers (easy)
Find the Duplicate Number (easy)
Find all Duplicate Numbers (easy)
6. Pattern: In-place Reversal of a LinkedList,鏈表翻轉
經典題目:
Reverse a LinkedList (easy)
Reverse a Sub-list (medium)
Reverse every K-element Sub-list (medium)
7. Pattern: Tree Breadth First Search,樹上的BFS
經典題目:
Binary Tree Level Order Traversal (easy)
Reverse Level Order Traversal (easy)
Zigzag Traversal (medium)
Level Averages in a Binary Tree (easy)
Minimum Depth of a Binary Tree (easy)
Level Order Successor (easy)
Connect Level Order Siblings (medium)
8. Pattern: Tree Depth First Search,樹上的DFS
經典題目:
Binary Tree Path Sum (easy)
All Paths for a Sum (medium)
Sum of Path Numbers (medium)
Path With Given Sequence (medium)
Count Paths for a Sum (medium)
9. Pattern: Two Heaps,雙堆類型
經典題目:
Find the Median of a Number Stream (medium)
Sliding Window Median (hard)
Maximize Capital (hard)
10. Pattern: Subsets,子集類型,一般都是使用多重DFS
經典題目:
Subsets (easy)
Subsets With Duplicates (easy)
Permutations (medium)
String Permutations by changing case (medium)
Balanced Parentheses (hard)
Unique Generalized Abbreviations (hard)
11. Pattern: Modified Binary Search,改造過的二分
經典題目:
Order-agnostic Binary Search (easy)
Ceiling of a Number (medium)
Next Letter (medium)
Number Range (medium)
Search in a Sorted Infinite Array (medium)
Minimum Difference Element (medium)
Bitonic Array Maximum (easy)
12. Pattern: Top ‘K’ Elements,前K個系列
經典題目:
Top ‘K’ Numbers (easy)
Kth Smallest Number (easy)
‘K’ Closest Points to the Origin (easy)
Connect Ropes (easy)
Top ‘K’ Frequent Numbers (medium)
Frequency Sort (medium)
Kth Largest Number in a Stream (medium)
‘K’ Closest Numbers (medium)
Maximum Distinct Elements (medium)
Sum of Elements (medium)
Rearrange String (hard)
13. Pattern: K-way merge,多路歸並
經典題目:
Merge K Sorted Lists (medium)
Kth Smallest Number in M Sorted Lists (Medium)
Kth Smallest Number in a Sorted Matrix (Hard)
Smallest Number Range (Hard)
14. Pattern: 0/1 Knapsack (Dynamic Programming),0/1背包類型
經典題目:
0/1 Knapsack (medium)
Equal Subset Sum Partition (medium)
Subset Sum (medium)
Minimum Subset Sum Difference (hard)
15. Pattern: Topological Sort (Graph),拓撲排序類型
經典題目:
Topological Sort (medium)
Tasks Scheduling (medium)
Tasks Scheduling Order (medium)
All Tasks Scheduling Orders (hard)
Alien Dictionary (hard)
大家好好練練這些題目,面試中遇到高等難度的題目,應該就能解得不錯了。
有需要的小伙伴,網站全部課程都有效的額外八折coupon code: awesome-developer-20
11.07.2019更新:在看完評論區小伙伴的留言之后,我又去找了他們的官方課程介紹,花了五個小時,翻譯完了,感興趣的同學可以去參考:
11.15.2019更新:增加了另外一個角度解析上面這些模式的翻譯文章:
如果對你有幫助,請點贊和關注計算機基礎知識和算法面試准備專欄:
其他很多課程:
窮碼農:網課黨的雙重大福利!Github學生賬號和Educative合作,總共2000美金的課程免費半年啦