> 文档中心 > LeetCode674. 最长连续递增序列

LeetCode674. 最长连续递增序列


思路

这道题和300. 最长递增子序列_想进阿里的小菜鸡的博客-CSDN博客很像。不同的是该题是要连续递增的,和300的区别就是不需要从0到i-1间找最大的递增序列,必须以i-1结束才可以。

代码

class Solution {    public int findLengthOfLCIS(int[] nums) { int dp[] = new int[nums.length]; Arrays.fill(dp,1); for(int i = 1;inums[i-1]){  dp[i] = dp[i-1]+1;     }else{  dp[i]=1;     } } int res=0; for(int i =0;i<dp.length;i++){     res=Math.max(res,dp[i]); } return res;    }}