From 6eadd3eafc7c55b2bd945041e4752c09b20b69ed Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Thu, 28 Dec 2023 10:03:01 +0800 Subject: [PATCH] =?UTF-8?q?Update.=E4=B9=B0=E5=8D=96=E8=82=A1=E7=A5=A8?= =?UTF-8?q?=E7=9A=84=E6=9C=80=E4=BD=B3=E6=97=B6=E6=9C=BA2=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0C#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0122.买卖股票的最佳时机II.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; + } +} +```