摘要: 图解找递推公式 const int N = 20; class Solution { public: int dp[N]; int numTrees(int n) { dp[0] = 1; for (int i = 1; i <= n; i ++) for (int j = 0; j <= i - 阅读全文
posted @ 2022-09-26 09:32 hjy94wo 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 二叉搜索树 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为二叉搜索树 /** * Definition for a binary tree node. * struct TreeNode { * 阅读全文
posted @ 2022-09-26 09:09 hjy94wo 阅读(13) 评论(0) 推荐(0) 编辑
摘要: const int N = 60; class Solution { public: int dp[N]; int integerBreak(int n) { dp[2] = 1; for (int i = 3; i <= n; i ++) for (int j = 1; j < i; j ++) 阅读全文
posted @ 2022-09-23 10:05 hjy94wo 阅读(15) 评论(0) 推荐(0) 编辑
摘要: dfs(超时) class Solution { public: int res = 0; void dfs(int i, int j, vector<vector<int>>& obstacleGrid) { if (i == obstacleGrid.size() - 1 && j == obs 阅读全文
posted @ 2022-09-22 19:04 hjy94wo 阅读(15) 评论(0) 推荐(0) 编辑
摘要: dfs(超时) class Solution { public: int res = 0; void dfs(int x, int y, int m, int n) { if (x == m && y == n) res ++; if (x + 1 <= m) dfs(x + 1, y, m, n) 阅读全文
posted @ 2022-09-22 16:45 hjy94wo 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 动态规划 const int N = 1000; class Solution { public: int dp[N]; int minCostClimbingStairs(vector<int>& cost) { dp[0] = cost[0]; dp[1] = cost[1]; for (int 阅读全文
posted @ 2022-09-22 15:52 hjy94wo 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 动态规划 const int N = 50; class Solution { public: int dp[N]; int climbStairs(int n) { dp[0] = 1; dp[1] = 1; for (int i = 2; i <= n; i ++) dp[i] = dp[i - 阅读全文
posted @ 2022-09-22 15:27 hjy94wo 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 动态规划 const int N = 40; class Solution { public: int dp[N]; int fib(int n) { dp[1] = 1; for (int i = 2; i <= n; i ++) dp[i] = dp[i - 1] + dp[i - 2]; re 阅读全文
posted @ 2022-09-22 15:15 hjy94wo 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 见c++ STL 阅读全文
posted @ 2022-09-19 10:04 hjy94wo 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 略 阅读全文
posted @ 2022-09-19 09:56 hjy94wo 阅读(4) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示