Longest Continuous Increasing Subsequence
最长连续递增子序列. local用来表示当前最长递增子序列, max表示全局最长递增子序列
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class Solution { public int findLengthOfLCIS(int[] nums) { if(nums == null || nums.length == 0) return 0; int max = 1; int local = 1; for(int i = 1 ; i < nums.length; i++) { if(nums[i-1] < nums[i]) { local++; } else { local = 1; } max = Math.max(max, local); } return max; } } |