diff --git a/problems/0122.买卖股票的最佳时机II.md b/problems/0122.买卖股票的最佳时机II.md index 2c2ab225..69706e36 100644 --- a/problems/0122.买卖股票的最佳时机II.md +++ b/problems/0122.买卖股票的最佳时机II.md @@ -406,6 +406,21 @@ object Solution { } } ``` +### C# +```csharp +public class Solution +{ + public int MaxProfit(int[] prices) + { + int res = 0; + for (int i = 0; i < prices.Length - 1; i++) + { + res += Math.Max(0, prices[i + 1] - prices[i]); + } + return res; + } +} +```