选自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