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 7924803

Browse files
committed
Update0376.摆动序列,添加C#
1 parent b01155f commit 7924803

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎problems/0376.摆动序列.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,27 @@ object Solution {
692692
}
693693
}
694694
```
695+
### C#
696+
```csharp
697+
public class Solution
698+
{
699+
public int WiggleMaxLength(int[] nums)
700+
{
701+
if (nums.Length < 2) return nums.Length;
702+
int curDiff = 0, preDiff = 0, res = 1;
703+
for (int i = 0; i < nums.Length - 1; i++)
704+
{
705+
curDiff = nums[i + 1] - nums[i];
706+
if ((curDiff > 0 && preDiff <= 0) || (curDiff < 0 && preDiff >= 0))
707+
{
708+
res++;
709+
preDiff = curDiff;
710+
}
711+
}
712+
return res;
713+
}
714+
}
715+
```
695716

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

0 commit comments

Comments
(0)

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