選自GitHub
作者:Sherali Obidov
機器之心編譯
參與:李亞洲、微胖、蔣思源
該資源是算法、數據結構以及面試問題解決方案的集合,裡面的 repository 包含了我對常見算法問題的解答以及數據結構的實現(用 Java)。該資源集合處於持續更新中。
項目地址:https://github.com/sherxon/AlgoDS
目前為止,該資源集合提供了算法、數據結構以及 200 道面試題的答案。
問題
問題被分成了三個等級:
簡單問題:http://suo.im/262F7q
中等問題:http://suo.im/11JBcd
困難問題:http://suo.im/3pTT1R
問題方向
針對以下不同面試問題,各自的連結中都給出了解決方案。
陣列(Arrays)
旋轉陣列(Rotate Array):http://suo.im/2Z3CMz
Contains Duplicate:http://suo.im/2E9xnW
發現峰值元素:http://suo.im/4gQO3k
最大化子陣列(Maximum Subarray):http://suo.im/N0TXd
陣列中第 k 最大的元素(Kth Largest Element in an Array):http://suo.im/2P7aIi
搜索陣列中的所有 Duplicates:http://suo.im/2wQwpw
最長增長子序列(Longest Increasing Subsequence):http://suo.im/PvJyK
旋轉圖像、矩陣(Rotate Image, matrix):http://suo.im/3BGG1x
攪亂陣列(Shuffle an Array):http://suo.im/3V5MBe
在旋轉陣列中搜索最小值:http://suo.im/2xtLa0
在旋轉陣列中搜索:http://suo.im/1Ued08
鍊表(linked list)
單鍊表實現:http://suo.im/2n3Kzr
雙向鍊表實現(Doubly Linked List):http://suo.im/1y98CP
刪除鍊表中的結點:http://suo.im/41ZByL
回文鍊表(Palindrome Linked List):http://suo.im/3OWugt
反向鍊表(Reverse Linked List):http://suo.im/OxjXQ
兩個鍊表的交集點(Intersection of Two Linked Lists):http://suo.im/36rPzZ
鍊表循環:http://suo.im/gANC2
從表的底部一處 Nth 節點:http://suo.im/4D3RNj
合併分類鍊表(Merge Sort List):http://suo.im/4jAMx3
發現鍊表循環:http://suo.im/2UFfZI
合併 k 分類列表:http://suo.im/4uWyyt
其他有關列表的問題:http://suo.im/4TyiJ
二叉樹(Binary Tree)
二叉樹的層次遍歷(Binary Tree Level Order Traversal):http://suo.im/1DRKTK
左葉節點求和(Sum of Left Leaves):http://suo.im/nZnDk
二叉樹轉置(Invert Binary Tree): http://suo.im/27dXUu
二叉搜索樹迭代器(Binary Search Tree Iterator):http://suo.im/4EgmWR
二叉樹後序遍歷(Binary Tree Postorder Traversal):http://suo.im/2I6r5S
二叉樹前序遍歷(Binary Tree Preorder Traversal):http://suo.im/1AF5J0
平面化二叉樹為鍊表(Flatten Binary Tree to Linked List):http://suo.im/46kRsP
對稱樹(Symmetric Tree):http://suo.im/BnxLJ
二叉樹中序遍歷(Binary Tree Inorder Traversal):http://suo.im/snOMr
相似樹(Same Tree):http://suo.im/1OCC7W
二叉樹最大深度(Maximum Depth of Binary Tree):http://suo.im/2KinyW
平衡二叉樹(Balanced Binary Tree):http://suo.im/3goksD
二叉樹最小深度(Minimum Depth of Binary Tree):http://suo.im/2f53cs
平衡二叉搜索樹排序列表(Sorted List to Balanced Binary Search Tree):http://suo.im/2D1MAo
驗證二叉搜索樹(Validate Binary Search Tree):http://suo.im/1lkBnt
平衡搜索樹排序列表(Sorted List to Balanced BST):http://suo.im/2Qr9IL
平衡搜索樹第 k 最小元素(Kth Smallest Element in a BST):http://suo.im/4mwq7K
二叉樹的之字形層序遍歷(Binary Tree Zigzag Level Order Traversal):http://suo.im/3NCvZW
平衡搜索樹的結點刪除(Delete Node in a BST):http://suo.im/1cXcP3
平衡樹的最小公共祖先(Lowest Common Ancestor of BST):http://suo.im/MBljD
二叉樹的左視圖(Binary Tree Left Side View):http://suo.im/1hzBvx
二叉樹的右視圖(Binary Tree Right Side View):http://suo.im/2Invga
平衡搜索樹的眾數(Mode in BST):http://suo.im/3Jyrn2
最高頻率子樹和(Most Frequent Subtree Sum):http://suo.im/35LlcZ
搜尋每行最大元素(Find Largest Element in Each Row):http://suo.im/32twya
其他樹型問題:http://suo.im/4TyiJ
數學
整數拆分(Integer Break):http://suo.im/lJU8r
逆位(Reverse Bits):http://suo.im/2E075a
迴文數:(Palindrome Number):http://suo.im/3pkhnt
冪(Math.pow):http://suo.im/1Wr3E9
壺和水的問題(Jug and Water Problem):http://suo.im/1gWPQG
愛拉託遜新篩法(Sieve of Eratosthenes):http://suo.im/Pi0G7
費馬素數(Fermat's primality):http://suo.im/2HZFT3
評估逆波蘭式表示法(Evaluate Reverse Polish Notation):http://suo.im/jIGg6
堆棧&隊列(Stack & Queue)
最小堆棧:http://suo.im/4FiVlB
最小隊列:http://suo.im/3KEtsq
使用隊列實現堆棧:http://suo.im/D5r2s
使用堆棧實現隊列:http://suo.im/171IwF
動態編程(Dynamic Programming)
斐波那契數列:http://suo.im/1zjJhk
詞內換行(word break):http://suo.im/3BIxnZ
子集和:http://suo.im/abSSP
0/1 漸縮問題:http://suo.im/1gVbIL
最短回文(KMP):http://suo.im/362qXW
MISC
並查:http://suo.im/24ZJmj
排列:http://suo.im/2NZx1s
子集:http://suo.im/PgGSw
算法方向
排序與搜索(Sorting And Searching)
上推排序:http://suo.im/2ofoaz
插入排序:http://suo.im/2unWJM
選擇排序:http://suo.im/2Sqldb
計算排序:http://suo.im/ZsIt7
二叉搜索,上下界:http://suo.im/10C1jM
歸併排序:http://suo.im/1iBDRS
快速排序:http://suo.im/1ZV7sc
圖(Graphs)
寬度優先搜索(BFS):http://suo.im/2GhGd8
深度優先搜索(DFS):http://suo.im/1xuHah
Prim 最小生成樹(MST):http://suo.im/34Ignu
KrusKal 最小生成樹(MST):無
拓撲排序:http://suo.im/2KxOO
最短路徑的戴克斯特拉算法(Dijsktra):http://suo.im/3uv4kJ
最短路徑的 Bellman-Ford 算法:http://suo.im/2HgD4k
啟發式路徑搜索(Heuristic Path Finding):http://suo.im/2pQoF6
二分圖:http://suo.im/29I5J1
字符串(String)
Rabin Karp 序列搜索:http://suo.im/3dUjZM
Ransom Note:http://suo.im/2fIVZc
逆字符串(Reverse String):http://suo.im/355a41
最長公共前綴(Longest Common Prefix):http://suo.im/1gt97D
Is 易位構詞(Anagram):http://suo.im/3BWyAQ
Needle and Haystack:http://suo.im/lXoT4
詞內換行(word break):http://suo.im/3BIxnZ
數據結構
樹(Trees)
二叉搜索樹(遞歸):http://suo.im/2I4nfe
二叉搜索樹(迭代):http://suo.im/1M2Q6Z
AVL 樹:http://suo.im/151lYW
Trie(Prefix 樹):http://suo.im/2evIeJ
本文為機器之心編譯,轉載請聯繫本公眾號獲得授權。
✄---
加入機器之心(全職記者/實習生):hr@jiqizhixin.com
投稿或尋求報導:editor@jiqizhixin.com
廣告&商務合作:bd@jiqizhixin.com