diff --git a/376-wiggle-subsequence/376-wiggle-subsequence.cpp b/376-wiggle-subsequence/376-wiggle-subsequence.cpp new file mode 100644 index 0000000..514633f --- /dev/null +++ b/376-wiggle-subsequence/376-wiggle-subsequence.cpp @@ -0,0 +1,19 @@ +class Solution { +public: + int wiggleMaxLength(vector& nums) { + if(nums.size()<=1){ + return nums.size(); + } + int upcount=1,downcount=1; + for(int i=0;inums[i+1]){ + downcount=upcount+1; + } + } + int ans = max(upcount,downcount); + return ans; + } +}; \ No newline at end of file