会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Danae丶
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
下一页
2021年8月11日
交错字符串
摘要: 题源:LeetCode 链接:https://leetcode-cn.com/problems/interleaving-string/ 这道题目可以考虑使用动态规划去完成 我们可以找到他的状态转移方程: 其中这个p为i+j-1。 代码实现如下: 1 class Solution { 2 publi
阅读全文
posted @ 2021-08-11 16:53 Danae丶
阅读(56)
评论(0)
推荐(0)
2021年8月10日
解码方法
摘要: 题源:LeetCode 链接:https://leetcode-cn.com/problems/decode-ways 这也是一道动态规划的题目,注意f(x)和f(x-1)、f(x-2)的关系 1 class Solution { 2 public: 3 int numDecodings(strin
阅读全文
posted @ 2021-08-10 10:43 Danae丶
阅读(63)
评论(0)
推荐(0)
2021年8月9日
最小路径和
摘要: 题源:LeetCode 链接:https://leetcode-cn.com/problems/minimum-path-sum/ 还是一道经典的动态规划题 1 class Solution { 2 public: 3 int minPathSum(vector<vector<int>>& grid
阅读全文
posted @ 2021-08-09 09:18 Danae丶
阅读(35)
评论(0)
推荐(0)
2021年8月8日
不同路径II
摘要: 题源:LeetCode 链接:https://leetcode-cn.com/problems/unique-paths-ii/ 其实和上一个随笔中的不同路径一样,只是多了个障碍物,多了个判断的过程。 1 class Solution { 2 public: 3 int uniquePathsWit
阅读全文
posted @ 2021-08-08 09:02 Danae丶
阅读(29)
评论(0)
推荐(0)
2021年8月6日
不同路径
摘要: 题源:leetcode 链接:https://leetcode-cn.com/problems/unique-paths/ 一道动态规划题,维护一个m*n的数组即可 1 class Solution { 2 public: 3 int uniquePaths(int m, int n) { 4 ve
阅读全文
posted @ 2021-08-06 12:36 Danae丶
阅读(25)
评论(0)
推荐(0)
2021年8月3日
跳跃游戏II
摘要: 题源:leetcode 链接:https://leetcode-cn.com/problems/jump-game-ii/ 这次讨论两种解法,一个dp一个贪心 贪心的方法: 1 class Solution { 2 public: 3 int jump(vector<int>& nums) { 4
阅读全文
posted @ 2021-08-03 16:03 Danae丶
阅读(44)
评论(0)
推荐(0)
最长回文子串
摘要: 题源:leetcode 链接:https://leetcode-cn.com/problems/longest-palindromic-substring/solution/zui-chang-hui-wen-zi-chuan-by-leetcode-solution/ 动态规划经典题 首先,每一个
阅读全文
posted @ 2021-08-03 09:35 Danae丶
阅读(34)
评论(0)
推荐(0)
2021年7月31日
无题2
摘要: 尝试了一下按照类型刷题,确实比乱刷会好一点 做完了力扣的十几个简单难度的dp,后面开始做中等难度了 还是代码写的太少了,数组的操作都需要上网查一下
阅读全文
posted @ 2021-07-31 15:54 Danae丶
阅读(16)
评论(0)
推荐(0)
第N个泰波那契数
摘要: 题源:leetcode 链接:https://leetcode-cn.com/problems/n-th-tribonacci-number/ 最简单的动态规划 1 class Solution { 2 public: 3 int tribonacci(int n) { 4 if(n==0) ret
阅读全文
posted @ 2021-07-31 15:37 Danae丶
阅读(35)
评论(0)
推荐(0)
2021年7月30日
除数博弈
摘要: 题源:leetcode 链接:https://leetcode-cn.com/problems/divisor-game/ 一开始就想到了数学方法,即return (n%2==0) 这里还有个动态规划的方法: 1 class Solution { 2 public: 3 bool divisorGa
阅读全文
posted @ 2021-07-30 11:03 Danae丶
阅读(43)
评论(0)
推荐(0)
上一页
1
2
3
4
下一页
公告