Update problems/0122.买卖股票的最佳时机II(动态规划).md

This commit is contained in:
fwqaaq
2023-06-03 14:59:17 +08:00
committed by GitHub
parent 2719dbdd0e
commit 2a6a8da5e0

View File

@ -385,7 +385,6 @@ impl Solution {
pub fn max_profit(prices: Vec<i32>) -> i32 {
let mut dp = vec![-prices[0], 0];
for p in prices {
// 可以看作 low、res
dp[0] = dp[0].max(dp[1] - p);
dp[1] = dp[1].max(dp[0] + p);
}