Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public int wiggleMaxLength(int[] nums) {
- if (nums == null || nums.length < 1) return 0;
- int high = 1;
- int low = 1;
- int len = nums.length;
- for (int i = 1; i < len; i++) {
- if (nums[i] > nums[i - 1]) high = low + 1;
- else if (nums[i] < nums[i - 1]) low = high + 1;
- }
- return Math.max(high, low);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement