mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 15:45:40 +08:00
Update problems/0122.买卖股票的最佳时机II(动态规划).md
This commit is contained in:
@ -385,7 +385,6 @@ impl Solution {
|
|||||||
pub fn max_profit(prices: Vec<i32>) -> i32 {
|
pub fn max_profit(prices: Vec<i32>) -> i32 {
|
||||||
let mut dp = vec![-prices[0], 0];
|
let mut dp = vec![-prices[0], 0];
|
||||||
for p in prices {
|
for p in prices {
|
||||||
// 可以看作 low、res
|
|
||||||
dp[0] = dp[0].max(dp[1] - p);
|
dp[0] = dp[0].max(dp[1] - p);
|
||||||
dp[1] = dp[1].max(dp[0] + p);
|
dp[1] = dp[1].max(dp[0] + p);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user