leetcode376

Posted asenyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode376相关的知识,希望对你有一定的参考价值。

 1 class Solution:
 2     def wiggleMaxLength(self, nums: List[int]) -> int:
 3         n = len(nums)
 4         if n == 0:
 5             return 0
 6         up,down = 1,1
 7         for i in range(1,n):
 8             if nums[i] > nums[i-1]:
 9                 up = down + 1
10             elif nums[i] < nums[i-1]:
11                 down = up + 1
12         return max(up,down)

 

以上是关于leetcode376的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode 376. Wiggle Subsequence

Leetcode376. Wiggle Subsequence

leetcode376

***Leetcode 376. Wiggle Subsequence

LeetCode.376 - Wiggle Subsequence

LeetCode 376. Wiggle Subsequence 摆动子序列