摘要:
leetcode acwing 动态规划 \(O(n^3)\) 想起了矩阵连乘 C++ 代码 class Solution { public: int maxCoins(vector<int>& nums) { int n = nums.size(); vector<int> a(n + 2, 1) 阅读全文
posted @ 2021-01-05 11:44
alexemey
阅读(79)
评论(0)
推荐(0)
摘要:
leetcode acwing 动态规划 \(O(n)\) 和之前做的完全平方数比较像 C++ 代码 class Solution { public: int coinChange(vector<int>& coins, int amount) { if (coins.empty()) return 阅读全文
posted @ 2021-01-05 11:10
alexemey
阅读(42)
评论(0)
推荐(0)
摘要:
leetcode acwing 动态规划 \(O(3n)\) 状态机DP,第一次碰见 C++ 代码 class Solution { public: int maxProfit(vector<int>& prices) { if (prices.empty()) return 0; int n = 阅读全文
posted @ 2021-01-05 10:49
alexemey
阅读(41)
评论(0)
推荐(0)
摘要:
leetcode acwing 动态规划 \(O(n\sqrt{n})\) C++ 代码 class Solution { public: int numSquares(int n) { vector<int> f(n + 1, n); f[0] = 0; for (int i = 1; i <= 阅读全文
posted @ 2021-01-05 10:14
alexemey
阅读(40)
评论(0)
推荐(0)
摘要:
leetcode acwing 动态规划 \(O(n)\) C++ 代码 class Solution { public: int maximalSquare(vector<vector<char>>& matrix) { int n = matrix.size(); int m = 0; if ( 阅读全文
posted @ 2021-01-05 09:42
alexemey
阅读(65)
评论(0)
推荐(0)

浙公网安备 33010602011771号