上一页 1 2 3 4 5 6 ··· 23 下一页
摘要: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed n 阅读全文
posted @ 2017-05-20 00:56 CodesKiller 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 两个算法都是跟求图的有源最短路径有关。Dijkstra主要针对的是无负权值节点的图,而Bellman-Ford算法则是可以处理有负权值的有向图的最短路径问题。两者都用到了一个“松弛计算”的方法,也就是在遍历图的顶点和边的过程中修改距离数组的值,从而来找出最短路径。 Dijkstra算法针对无负权值的 阅读全文
posted @ 2017-04-01 07:21 CodesKiller 阅读(4224) 评论(0) 推荐(1) 编辑
摘要: To understand the difference between polynomial time and pseudopolynomial time, we need to start off by formalizing what "polynomial time" means. The 阅读全文
posted @ 2017-04-01 06:35 CodesKiller 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 动态规划算法的基本要素: 1 最优子结构性质当问题的最优解包含了其子问题的最优解时,称该问题具有最优子结构性质。2 重叠子问题性质 动态规划算法对每个问题只解一次,将其解保存在一个表格中,当再次需要解此问题时,用常数时间查看一下结果。因此,用动态规划算法通常只需要多项式时间。 备忘录方法:•用一个表 阅读全文
posted @ 2017-03-28 07:01 CodesKiller 阅读(1164) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in 阅读全文
posted @ 2017-03-24 11:35 CodesKiller 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, ex 阅读全文
posted @ 2017-03-24 08:39 CodesKiller 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floati 阅读全文
posted @ 2017-03-24 07:13 CodesKiller 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floati 阅读全文
posted @ 2017-03-24 02:57 CodesKiller 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's 阅读全文
posted @ 2017-03-24 01:44 CodesKiller 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the n 阅读全文
posted @ 2017-03-24 01:10 CodesKiller 阅读(187) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 23 下一页