first share...


  • 0
    Y
    class Solution {
    public:
        int wiggleMaxLength(vector<int>& nums) {
            int len=nums.size();
            if(len<2) return len;
            int  slen=1, blen=1;
            for (int i=1; i<len; i++) {
                if(nums[i]>nums[i-1]) 
                    blen=slen+1;
                else if(nums[i]<nums[i-1]) 
                    slen=blen+1;
            }
            return max(slen,blen);
        }
    };
    

  • 0

    @yanxinseu Please try to use ``` backquotes (right below the ESC button) to format your code properly, thank you. This is really hard to read.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.