We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fe0abe7 commit ccfdd97Copy full SHA for ccfdd97
problems/0376.摆动序列.md
@@ -143,7 +143,23 @@ Python:
143
Go:
144
145
146
-
+Javascript:
147
+```Javascript
148
+var wiggleMaxLength = function(nums) {
149
+ if(nums.length <= 1) return nums.length
150
+ let result = 1
151
+ let preDiff = 0
152
+ let curDiff = 0
153
+ for(let i = 0; i <= nums.length; i++) {
154
+ curDiff = nums[i + 1] - nums[i]
155
+ if((curDiff > 0 && preDiff <= 0) || (curDiff < 0 && preDiff >= 0)) {
156
+ result++
157
+ preDiff = curDiff
158
+ }
159
160
+ return result
161
+};
162
+```
163
164
-----------------------
165
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
0 commit comments