Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. public class Solution {
  2. public int wiggleMaxLength(int[] nums) {
  3. if (nums == null || nums.length < 1) return 0;
  4. int high = 1;
  5. int low = 1;
  6. int len = nums.length;
  7. for (int i = 1; i < len; i++) {
  8. if (nums[i] > nums[i - 1]) high = low + 1;
  9. else if (nums[i] < nums[i - 1]) low = high + 1;
  10. }
  11. return Math.max(high, low);
  12.  
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement