摘要: 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 阅读(19) 评论(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 阅读(17) 评论(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 阅读(21) 评论(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 阅读(13) 评论(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 阅读(15) 评论(0) 推荐(0)