
leetcode
XueWang1
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode 124. Binary Tree Maximum Path Sum
地址:https://leetcode.com/problems/binary-tree-maximum-path-sum/Given anon-emptybinary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starti...原创 2019-04-07 02:50:58 · 209 阅读 · 0 评论 -
Best Time to Buy and Sell Stock IV-买卖股票问题
leetcode原题地址:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/REFERENCE:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/discuss/135704/Detail-explanation-of-DP-so...原创 2019-05-14 01:14:49 · 283 阅读 · 0 评论 -
leetcode-322 零钱兑换--完全背包问题
原题地址:https://leetcode.com/problems/coin-change/这个题目可以用dfs来写,但是很容易超时,需要剪枝。dp中有经典的背包九讲,而此题目正好是一种完全背包的模型。首先看完全背包模型:有 N 种物品和一个容量为 V 的背包,每种物品都有无限件可用。放入第 i 种物品 的费用是 Ci,价值是 Wi。求解:将哪些物品装入背包,可使这些物品的耗费的...原创 2019-08-09 12:00:56 · 1137 阅读 · 2 评论 -
力扣双周赛--最小生成树的应用
https://leetcode-cn.com/contest/biweekly-contest-7/problems/optimize-water-distribution-in-a-village/这个题目可以转化为最小生成树。构建虚拟结点0,并且将所有结点与之联系,长度为wi,如下:然后对改图求最小生成树,即可求得最小cost。struct Edge{ int ...原创 2019-08-25 01:15:43 · 890 阅读 · 1 评论 -
霍夫曼的应用--leetcode 1167
https://leetcode.com/problems/minimum-cost-to-connect-sticks/思路,将两个短的求和,然后放入数列中;再取两个短的;因此是霍夫曼树。使用优先级队列即可:class Solution {public: int connectSticks(vector<int>& sticks) { ...原创 2019-08-25 02:15:50 · 1072 阅读 · 0 评论