Skip to content

674. 最长连续递增序列 #5

@yifanzheng

Description

@yifanzheng

leetCode 地址:674. 最长连续递增序列

题解

贪心

public int findLengthOfLCIS(int[] nums) {
   int len = nums.length;
   if (len <= 1) {
     return len;
   }
   int lp = 0, rp = 1;
   int maxLen = 0;
   while (lp < len && rp < len) {
      if (nums[rp-1] >= nums[rp]) {
        lp = rp;
      }
      rp++;
      maxLen = Math.max(maxLen, rp - lp);
   }

   return maxLen;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions