摘要:
problem:https://leetcode.com/problems/counting-bits 爬台阶类型。我的做法是num拆分为比它小的最大2^n的值加上另一个数,然后这两个的dp叠加。 阅读全文
posted @ 2019-08-10 17:31
fish1996
阅读(157)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/create-maximum-number/ 分治。计算第一个数组最大的和第二个数组最大的,然后结合起来找最大的。 阅读全文
posted @ 2019-08-10 17:21
fish1996
阅读(284)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/remove-k-digits 单调栈。维护一个递增的栈,每pop一次意味着移除了一个元素,k--。减为0时不再移除。前导0处理起来很麻烦,很容易WA。 阅读全文
posted @ 2019-08-10 16:18
fish1996
阅读(121)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/perfect-squares 数字类dp。查找当前数字减去一个平方数对应的最小拆分次数。 阅读全文
posted @ 2019-08-10 13:56
fish1996
阅读(91)
评论(0)
推荐(0)
摘要:
problem: https://leetcode.com/problems/ugly-number-ii 大的ugly number是由小的ugly number乘以系数2, 3, 5得到的,每次相乘后,取最小的作为下一个,然后把最小的值的当前指针向后挪一位。(用vector封装了一下速度更慢了, 阅读全文
posted @ 2019-08-10 13:34
fish1996
阅读(115)
评论(0)
推荐(0)
摘要:
problem: https://leetcode.com/problems/house-robber-ii/ 多状态转换dp。我的方法是维护了四个状态。用两趟dp的基本思想也是多个状态。 阅读全文
posted @ 2019-08-10 12:27
fish1996
阅读(157)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/dungeon-game 看了这道题的tag我用了二分 + 简化dp(只需求特定血量能否达到)来做,能过但是速度好慢。一看评论区发现大家都是用纯dp过的,我哭了。 阅读全文
posted @ 2019-08-10 11:47
fish1996
阅读(177)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/maximum-product-subarray 类似买卖股票,需要维护两个状态,当前最大数和最小数。 阅读全文
posted @ 2019-08-10 01:01
fish1996
阅读(93)
评论(0)
推荐(0)
摘要:
problem:https://leetcode.com/problems/word-break/ 划分类型问题。 阅读全文
posted @ 2019-08-10 00:16
fish1996
阅读(164)
评论(0)
推荐(0)

浙公网安备 33010602011771号