GitHub高星!網際網路公司最常見的面試算法題大集合

2021-01-14 新智元

來源: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:



簡單難度


🖊 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主要分為兩個部分:一部分是關鍵點到題目的映射,另一部分是題目到思路,關鍵點,代碼的映射。


全部卡片都在:

https://github.com/azl397985856/leetcode/blob/master/assets/anki/leetcode.apkg


使用方法


anki - 文件 - 導入 - 下拉格式選擇「打包的 anki集合」,然後選中你下載好的文件,確定即可。更多關於anki使用方法的請查看:

https://apps.ankiweb.net/


目前已更新卡片一覽(僅列舉正面):



二分法解決問題的關鍵點是什麼,相關問題有哪些

如何用棧的特點來簡化操作, 涉及到的題目有哪些?

雙指針問題的思路以及相關題目有哪些?

滑動窗口問題的思路以及相關題目有哪些?

回溯法解題的思路以及相關題目有哪些?


494.target-sum:

https://github.com/azl397985856/leetcode/blob/master/todo/494.target-sum.js


609.find-duplicate-file-in-system:

https://github.com/azl397985856/leetcode/blob/master/todo/609.find-duplicate-file-in-system.js


10.regular-expression-matching:

https://github.com/azl397985856/leetcode/blob/master/todo/10.regular-expression-matching.js


365.water-and-jug-problem:

https://github.com/azl397985856/leetcode/blob/master/todo/365.water-and-jug-problem.js


anki 卡片 完善:

https://github.com/azl397985856/leetcode/blob/master/assets/anki


字符串類問題匯總:

https://github.com/azl397985856/leetcode/blob/master/todo/str/


參考連結:

https://github.com/azl397985856/leetcode

新智元春季招聘開啟,一起弄潮 AI 之巔!

崗位詳情請戳:


【加入社群】


新智元 AI 技術 + 產業社群招募中,歡迎對 AI 技術 + 產業落地感興趣的同學,加小助手微信號:aiera2015_2   入群;通過審核後我們將邀請進群,加入社群後務必修改群備註(姓名 - 公司 - 職位;專業群審核較嚴,敬請諒解)。

相關焦點

  • 面試資源、公共API、多樣化學習路徑,這10個GitHub庫開發者必看
    GitHub 是共享各種技術、框架、庫和集合的頭號平臺,越來越多的人到該平臺尋找最有用的庫。本文作者全棧工程師 Simon Holdorf 列舉了十個能夠為所有軟體工程師提供巨大價值的 GitHub 庫。這些庫均具備大量 GitHub 星數,顯示其關聯性、流行性和效用。
  • 五分鐘學編程:怎樣才能學好筆試面試最愛考察的算法
    第二次認識算法,還是在研究生期間找實習工作的時候,面試的時候總有一些關於算法知識的考察,這些算法題比之前自己學數據結構的時候要更難一些,比如要讓你描述一下快排的過程,或者是二分查找的過程,由於是電話面試居多,一般都不會考察太複雜的問題。第三次認識算法,是在面試了頭條這類對算法要求極高的公司之後。
  • 《Python程式設計師面試算法寶典》PDF超清版開源了文末附下載方式
    、分類歸納,提煉出算法面試的各種應對技巧,是一本Python程式設計師算法面試的圖書寶典。這裡,不僅介紹了程式設計師算法面試中的「萬能公式」,而且通過具體的實例從多角度剖析各類算法面試題,為讀者建立了一個完整的算法面試的方案資料庫,讓讀者快速理解全書內容、做到胸有成竹應對面試的同時,也為未來的職業發展鋪平道路。
  • 嵌入式工程師常見面試題大集合,找工作面試很重要
    上個星期,去深圳一家搞ARM開發的公司面試,HR叫我做了一份卷子,裡面都是C編程,心中暗喜,因為這些題基本上都在程式設計師面試寶典裡見過。本文引用地址:http://www.eepw.com.cn/article/201807/383391.htm  後來回到學校,在網上搜索,原來這些題都是嵌入式工程師的經典面試題目,很多網站上都可以找得到。現把他貼出來,附上網上的答案,跟大家分享,因為這些題實在太經典了。  1 .
  • 程式設計師面試題,200億個數字找中位數,不給分桶算法,怎麼辦?
    海量數據裡面如何尋找一堆數字的中位數,是一道非常常見的面試題。據稱,這個題目是騰訊前首席技術執行官Tony推崇的一個面試題,被加入的騰訊的面試題題庫。今天我們就來討論下這個題目,有一個存放著200億個數字的文件,存放著32位整型,可能會有重複的數字,現在想從這堆數字中找到他們的中位數。
  • Top30數據分析師常見面試題(附答案)!
    各大網際網路公司都在不斷完善自己的數據分析團隊,數據分析師的薪酬也是水漲船高。業內人士透露,應屆畢業生的平均薪資大概在6K左右,1至3年經驗的大概在10K到20K之間,5至10年經驗的大概在25K以上。薪資還是十分誘人的,那麼,如何快速成長為一名年薪百萬的數據分析師呢?快來看看,以下30道數據分析相關面試題,你會多少?1、分析數據還要寫java代碼是不是效率有點低?
  • 2012長沙小升初面試:九道自測題你會做幾道?
    小升初面試是2012年長沙小升初擇校的一個重要階段,學校一般會藉由這個階段來判斷學生的性格和知識面的涵蓋廣不廣,下面奧數網編輯收集了長沙各大名校2011年小升初面試的部分問題,看看你會答幾題?   1.二十八星宿有哪些?   2.沿著赤道往東走,能繞地球一圈嗎?   3.刷牙的時候牙刷是橫著刷還是豎著刷?
  • 算法工程師路線圖(經驗濃縮,純乾貨!)
    說起算法(Algorithm),需要值得注意的是,數據結構與算法,機器學習算法都可簡稱為算法,但兩者是完全不同的。數據結構與算法是計算機科學中的一門基礎課程,主要內容是關於如何設計電腦程式,使得程序能夠運行更快,佔用內存更少。通常所說的程式設計師面試要刷算法題,指的便是數據結構與算法中的算法。
  • 簡單又常見的算法題:漢諾塔
    (給算法愛好者加星標
  • 2021銀保監會面試專業題考情概括,助你高效避雷!
    最近這幾天收到很多小夥伴的諮詢,抱怨銀保監會面試難度很大,想知道銀保監會面試該如何準備?其實銀保監會面試難主要是面試題目數量大,還涉及專業題和英語題。那麼銀保監會面試該如何準備才能拿到高分呢?接下來我會從各個維度來給大家展開細說。一、面試形式及題量歷年採取結構化面試方式,未出現無領導小組討論、半結構化面試等其他形式。
  • 高效「背誦」面試題的三定法則
    你會驚奇地發現,這些面試題無非就是這三大類,分別是有 固定答案的封閉式問題 考你理解深度的開放式問題 考你編程能力的邏輯算法題 舉例說明:
  • 拼多多2020屆數據分析面試題合集
    ,為什麼現在選擇網際網路產品數據分析?然後他安慰說可以理解,畢竟我平常都是在學校寫python沒怎麼寫過SQL(結果關於python或者算法的兩個技術面一點都沒問orz)然後問了一個情景題,這題答得是個人目前面試經歷裡最尷尬的,因為完全沒有理解他問的意思,其實是一些基於業務的描述性統計問題(真的只需要描述),是我想的太複雜了,是真沒想到會問那麼基礎,全程一臉懵。
  • 網際網路技術筆試總通不過?leetcode刷對了麼
    今天,逆行君就帶你從世界觀和方法論兩方面走進「leetcode」 簡單來說,leetcode是一個美國的在線編程網站,它收集了各大公司的經典算法面試題,用戶可以選擇不同的語言進行代碼的在線編寫、編譯和調試。
  • 你面試穩了!通關LeetCode刷題完整攻略,省時又高效
    使得:小的數字都放在一起,大的放在另外一半。雙堆模式就能高效解決此類問題。正如名字所示,該模式用到了兩個堆,是不是很難猜?一個最小堆用來找最小元素;一個最大堆,拿到最大元素。這種模式將一半的元素放在最大堆中,這樣你可以從這一堆中秒找到最大元素。同理,把剩下一半丟到最小堆中,O(1)時間找到他們中的最小元素。
  • 常考算法面試題系列:鍊表的操作
    鍊表鍊表存儲有序的元素集合,但不同於數組,鍊表中每個元素在內存中並不是連續放置的。
  • 985碩,秋招面試30家企業,怒斬阿里、字節、美團offer
    數據結構與算法:劍指offer+LeetCode樓主是個跨專業選手,從去年9月研究生開學之後,開始學習數據結構與算法,最開始是學的算法導論那本書,邊學邊敲,課後題也跟著做,當時是第一次接觸DFS、BFS、回溯、二分、貪心、動態規劃等等算法。算法導論用了一個月左右時間過了一遍,對基本的數據結構和算法有了全新的認識。
  • python實戰14遞歸算法實現斐波那契數列(BAT面試題)
    某一線大廠面試題用非遞歸算法實現斐波那契數列儘量用高效的遞歸算法實現斐波那契數列參考答案非遞歸算法遞歸算法
  • 2021屆秋招大廠高頻算法題匯總
    當初在準備秋招的時候,算法是一個大難題,不知道該怎麼準備,也不知道應該要刷哪些題,只能在網上看面經,然後整理一遍,下面這些題目主要來源三個方面,(1)我自己遇到的真題(2)牛客上的面經,別人遇到的真題(3)有一些大佬github上整理的,我也整理了進來。
  • 去BAT,你應該要看一看的面試經驗總結
    先交代下背景:坐標上海,做技術開發,我本人面試的職位是linux伺服器開發,最傾向的職位是伺服器開發主程或技術經理。我本人也是上幾家公司的面試官,因為接下來幾年面臨著成家,技術上也到了瓶頸期,雖然拿了不少offer,但是想綜合比對一下,於是就參加了很多的面試。
  • 算法中的微積分:5大函數求導公式讓你在面試中脫穎而出
    例如包含了K近鄰算法、K均值、決策樹等算法的機器學習算法庫Scikit-learn,或者Keras,都可以幫助人們構建神經網絡架構,而不必了解卷積神經網絡CNNs或是循環神經網絡RNNs背後的細節。然而,想要成為一名優秀的機器學習工程師需要的遠不止這些。