diff --git a/problems/0121.买卖股票的最佳时机.md b/problems/0121.买卖股票的最佳时机.md index 753cb106..be8630f5 100644 --- a/problems/0121.买卖股票的最佳时机.md +++ b/problems/0121.买卖股票的最佳时机.md @@ -510,7 +510,22 @@ public class Solution } ``` +Rust: +> 贪心 + +```rust +impl Solution { + pub fn max_profit(prices: Vec) -> i32 { + let (mut low, mut res) = (i32::MAX, 0); + for p in prices { + low = p.min(low); + res = res.max(p - low); + } + res + } +} +```