Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6eadd3e

Browse files
committed
Update.买卖股票的最佳时机2,添加C#
1 parent a937b76 commit 6eadd3e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎problems/0122.买卖股票的最佳时机II.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,21 @@ object Solution {
406406
}
407407
}
408408
```
409+
### C#
410+
```csharp
411+
public class Solution
412+
{
413+
public int MaxProfit(int[] prices)
414+
{
415+
int res = 0;
416+
for (int i = 0; i < prices.Length - 1; i++)
417+
{
418+
res += Math.Max(0, prices[i + 1] - prices[i]);
419+
}
420+
return res;
421+
}
422+
}
423+
```
409424

410425
<p align="center">
411426
<a href="https://programmercarl.com/other/kstar.html" target="_blank">

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /