GitHub高星!互聯網公司最常見的面試演算法題大集合
新智元報道
來源:Github
編輯:元子
【新智元導讀】LeetCode是一個美國的在線編程網站,收集了各個大廠的筆試面試題,對找工作的畢業生和開發者來說,非常有價值。很多求職者都會在LeetCode刷上一遍,面試官也喜歡在上面挑選各類題目。
LeetCode是一個美國的在線編程網站,收集了各個大廠的筆試面試題,對找工作的畢業生和開發者來說,非常有價值。不過LeetCode上面的題目很多都是考察應聘者對基礎知識的應用,適合進行練習編程基礎或者準備面試。
很多求職者都會在LeetCode刷上一遍,面試官也喜歡在上面挑選各類題目。今天新智元給大家推薦的這個GitHub項目,是Repo主自己刷題的心路歷程,並給出了解題參考。該項目目前分為四個部分:
第一個部分是 leetcode 經典題目的解析,包括思路,關鍵點和具體的代碼實現
第二部分是對於數據結構與演算法的總結
第三部分是 anki 卡片, 將 leetcode 題目按照一定的方式記錄在 anki 中,方便大家記憶
第四部分是計劃, 這裡會記錄將來要加入到以上三個部分內容
只有熟練掌握基礎的數據結構與演算法,才能對複雜問題迎刃有餘。
食用指南
最近添加的部分, 前面會有 標註;最近更新的部分,前面會有 標註;將來會在這裡更新anki卡片。
leetcode官方賬號在知乎上給出的一個《互聯網公司最常見的面試演算法題有哪些?》的答案,原文地址:
https://www.zhihu.com/question/24964987/answer/586425979
一張互聯網公司面試中經常考察的問題類型總結的思維導圖,我們可以結合圖片中的信息分析一下。
其中演算法,主要是以下幾種:
基礎技巧:分治、二分、貪心
排序演算法:快速排序、歸併排序、計數排序
搜索演算法:回溯、遞歸、深度優先遍歷,廣度優先遍歷,二叉搜索樹等
圖論:最短路徑、最小生成樹
動態規劃:背包問題、最長子序列
數據結構,主要有如下幾種:
數組與鏈表:單 / 雙向鏈表
棧與隊列
哈希表
堆:最大堆 / 最小堆
樹與圖:最近公共祖先、並查集
字元串:前綴樹(字典樹) / 後綴樹
精彩預告
42.trapping-rain-water-1(雨水收集問題):
瀏覽器中的棧:
回溯法解題:
875. koko-eating-bananas:
傳送門
leetcode 經典題目的解析
簡單難度
20. Valid Parentheses:
https://github.com/azl397985856/leetcode/blob/master/problems/20.validParentheses.md
26.remove-duplicates-from-sorted-array:
https://github.com/azl397985856/leetcode/blob/master/problems/26.remove-duplicates-from-sorted-array.md
88.merge-sorted-array:
https://github.com/azl397985856/leetcode/blob/master/problems/88.merge-sorted-array.md
136.single-number:
https://github.com/azl397985856/leetcode/blob/master/problems/136.single-number.md
167.two-sum-ii-input-array-is-sorted:
https://github.com/azl397985856/leetcode/blob/master/problems/167.two-sum-ii-input-array-is-sorted.md
169.majority-element:
https://github.com/azl397985856/leetcode/blob/master/problems/169.majority-element.md
190.reverse-bits:
https://github.com/azl397985856/leetcode/blob/master/problems/190.reverse-bits.md
191.number-of-1-bits:
https://github.com/azl397985856/leetcode/blob/master/problems/191.number-of-1-bits.md
203.remove-linked-list-elements:
https://github.com/azl397985856/leetcode/blob/master/problems/203.remove-linked-list-elements.md
206.reverse-linked-list:
https://github.com/azl397985856/leetcode/blob/master/problems/206.reverse-linked-list.md
219.contains-duplicate-ii:
https://github.com/azl397985856/leetcode/blob/master/problems/219.contains-duplicate-ii.md
226.invert-binary-tree:
https://github.com/azl397985856/leetcode/blob/master/problems/226.invert-binary-tree.md
283.move-zeroes:
https://github.com/azl397985856/leetcode/blob/master/problems/283.move-zeroes.md
349.intersection-of-two-arrays:
https://github.com/azl397985856/leetcode/blob/master/problems/349.intersection-of-two-arrays.md
中等難度
2. Add Two Numbers:
https://github.com/azl397985856/leetcode/blob/master/problems/2.addTwoNumbers.md
3. Longest Substring Without Repeating Characters:
https://github.com/azl397985856/leetcode/blob/master/problems/3.longestSubstringWithoutRepeatingCharacters.md
11.container-with-most-water:
https://github.com/azl397985856/leetcode/blob/master/problems/11.container-with-most-water.md
19. Remove Nth Node From End of List:
https://github.com/azl397985856/leetcode/blob/master/problems/19.removeNthNodeFromEndofList.md
24. Swap Nodes In Pairs:
https://github.com/azl397985856/leetcode/blob/master/problems/24.swapNodesInPairs.md
39.combination-sum:
https://github.com/azl397985856/leetcode/blob/master/problems/39.combination-sum.md
40.combination-sum-ii:
https://github.com/azl397985856/leetcode/blob/master/problems/40.combination-sum-ii.md
46.permutations:
https://github.com/azl397985856/leetcode/blob/master/problems/46.permutations.md
47.permutations-ii:
https://github.com/azl397985856/leetcode/blob/master/problems/47.permutations-ii.md
55.jump-game:
https://github.com/azl397985856/leetcode/blob/master/problems/55.jump-game.md
62.unique-paths:
https://github.com/azl397985856/leetcode/blob/master/problems/62.unique-paths.md
75.sort-colors:
https://github.com/azl397985856/leetcode/blob/master/problems/75.sort-colors.md
78.subsets:
https://github.com/azl397985856/leetcode/blob/master/problems/78.subsets.md
86.partition-list:
https://github.com/azl397985856/leetcode/blob/master/problems/86.partition-list.md
90.subsets-ii:
https://github.com/azl397985856/leetcode/blob/master/problems/90.subsets-ii.md
92.reverse-linked-list-ii:
https://github.com/azl397985856/leetcode/blob/master/problems/92.reverse-linked-list-ii.md
94.binary-tree-inorder-traversal:
https://github.com/azl397985856/leetcode/blob/master/problems/94.binary-tree-inorder-traversal.md
102.binary-tree-level-order-traversal:
https://github.com/azl397985856/leetcode/blob/master/problems/102.binary-tree-level-order-traversal.md
103.binary-tree-zigzag-level-order-traversal:
https://github.com/azl397985856/leetcode/blob/master/problems/103.binary-tree-zigzag-level-order-traversal.md
139.word-break:
https://github.com/azl397985856/leetcode/blob/master/problems/139.word-breakmd
144.binary-tree-preorder-traversal:
https://github.com/azl397985856/leetcode/blob/master/problems/144.binary-tree-preorder-traversal.md
150.evaluate-reverse-polish-notation:
https://github.com/azl397985856/leetcode/blob/master/problems/150.evaluate-reverse-polish-notation.md
152.maximum-product-subarray:
https://github.com/azl397985856/leetcode/blob/master/problems/152.maximum-product-subarray.md
199.binary-tree-right-side-view:
https://github.com/azl397985856/leetcode/blob/master/problems/199.binary-tree-right-side-view.md
201.bitwise-and-of-numbers-range:
https://github.com/azl397985856/leetcode/blob/master/problems/201.bitwise-and-of-numbers-range.md
208.implement-trie-prefix-tree:
https://github.com/azl397985856/leetcode/blob/master/problems/208.implement-trie-prefix-tree.md
209.minimum-size-subarray-sum:
https://github.com/azl397985856/leetcode/blob/master/problems/209.minimum-size-subarray-sum.md
236.lowest-common-ancestor-of-a-binary-tree:
https://github.com/azl397985856/leetcode/blob/master/problems/236.lowest-common-ancestor-of-a-binary-tree.md
238.product-of-array-except-self:
https://github.com/azl397985856/leetcode/blob/master/problems/238.product-of-array-except-self.md
240.search-a-2-d-matrix-ii:
https://github.com/azl397985856/leetcode/blob/master/problems/240.search-a-2-d-matrix-ii.md
279.perfect-squares:
https://github.com/azl397985856/leetcode/blob/master/problems/279.perfect-squares.md
322.coin-change:
https://github.com/azl397985856/leetcode/blob/master/problems/322.coin-change.md
334.increasing-triplet-subsequence:
https://github.com/azl397985856/leetcode/blob/master/problems/334.increasing-triplet-subsequence.md
328.odd-even-linked-list:
https://github.com/azl397985856/leetcode/blob/master/problems/328.odd-even-linked-list.md
416.partition-equal-subset-sum:
https://github.com/azl397985856/leetcode/blob/master/problems/416.partition-equal-subset-sum.md
445.add-two-numbers-ii:
https://github.com/azl397985856/leetcode/blob/master/problems/445.add-two-numbers-ii.md
518.coin-change-2:
https://github.com/azl397985856/leetcode/blob/master/problems/518.coin-change-2.md
875.koko-eating-bananas:
https://github.com/azl397985856/leetcode/blob/master/problems/875.koko-eating-bananas.md
877.stone-game:
https://github.com/azl397985856/leetcode/blob/master/problems/877.stone-game.md
887.super-egg-drop:
https://github.com/azl397985856/leetcode/blob/master/problems/887.super-egg-drop.md
900.rle-iterator:
https://github.com/azl397985856/leetcode/blob/master/problems/900.rle-iterator.md
困難難度
23.merge-k-sorted-lists
https://github.com/azl397985856/leetcode/blob/master/problems/23.merge-k-sorted-lists.md
42.trapping-rain-water
https://github.com/azl397985856/leetcode/blob/master/problems/42.trapping-rain-water.md
128.longest-consecutive-sequence
https://github.com/azl397985856/leetcode/blob/master/problems/128.longest-consecutive-sequence.md
145.binary-tree-postorder-traversal
https://github.com/azl397985856/leetcode/blob/master/problems/145.binary-tree-postorder-traversal.md
146.lru-cache
https://github.com/azl397985856/leetcode/blob/master/problems/146.lru-cache.md
239.sliding-window-maximum
https://github.com/azl397985856/leetcode/blob/master/problems/239.sliding-window-maximum.md
295.find-median-from-data-stream.md
https://github.com/azl397985856/leetcode/blob/master/problems/295.find-median-from-data-stream.md
301.remove-invalid-parentheses
https://github.com/azl397985856/leetcode/blob/master/problems/301.remove-invalid-parentheses.md
數據結構與演算法的總結
數據結構:
https://github.com/azl397985856/leetcode/blob/master/thinkings/basic-data-structure.md(草稿)
二叉樹的遍歷:
https://github.com/azl397985856/leetcode/blob/master/thinkings/binary-tree-traversal.md
動態規劃:
https://github.com/azl397985856/leetcode/blob/master/thinkings/dynamic-programming.md
哈夫曼編碼和遊程編碼:
https://github.com/azl397985856/leetcode/blob/master/thinkings/run-length-encode-and-huffman-encode.md
布隆過濾器:
https://github.com/azl397985856/leetcode/blob/master/thinkings/bloom-filter.md
anki 卡片
Anki主要分為兩個部分:一部分是關鍵點到題目的映射,另一部分是題目到思路,關鍵點,代碼的映射。
全部卡片都在:
https://github.com/azl397985856/leetcode/blob/master/assets/anki/leetcode.apkg
使用方法
※對比了Github上5000份Python開源之後,大神精選了36個項目
TAG:新智元 |