Leetcode 674 最长连续子序列
JAVA:
public final int findLengthOfLCIS(int[] nums) { if (nums.length < 2) return nums.length; int len = nums.length, left = 0, right = 1, re = 0; while (left < len && right < len) { int currRe = 1; while (nums[right] > nums[left]) { currRe++; left++; right++; if (right == len) return Math.max(currRe, re); } if (currRe > re) re = currRe; left = right; right++; } return re; }
JS:
/** * @param {number[]} nums * @return {number} */ var findLengthOfLCIS = function (nums) { let len = nums.length; if (len < 2) return len; let left = 0, right = 1, re = 0; while (right < len) { let currRe = 1; while (right < len && nums[right] > nums[left]) { left++; right++; currRe++; } re = re > currRe ? re : currRe; left=right; right++; } return re; };
当你看清人们的真相,于是你知道了,你可以忍受孤独