From 1176b756a9b82c282c5aa05c539402f6805d9f85 Mon Sep 17 00:00:00 2001 From: X-shuffle <53906918+X-shuffle@users.noreply.github.com> Date: Fri, 23 Jul 2021 10:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=200376.=E6=91=86=E5=8A=A8?= =?UTF-8?q?=E5=BA=8F=E5=88=97=20go=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加 0376.摆动序列 go版本 --- problems/0376.摆动序列.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/problems/0376.摆动序列.md b/problems/0376.摆动序列.md index 4d283eb0..f64e0043 100644 --- a/problems/0376.摆动序列.md +++ b/problems/0376.摆动序列.md @@ -151,7 +151,24 @@ class Solution: ``` Go: - +```golang +func wiggleMaxLength(nums []int) int { + var count,preDiff,curDiff int + count=1 + if len(nums)<2{ + return count + } + for i:=0;i 0 && preDiff <= 0) || (preDiff >= 0 && curDiff < 0){ + preDiff=curDiff + count++ + } + } + return count +} +``` Javascript: ```Javascript