public int lengthOfLIS (int[] seeds) { // write code here int n=seeds.length; if(n<2) return n; int[] dp=new int[n]; Arrays.fill(dp,1); int res=0; for(int i=1;i<n;i++){ if(seeds[i-1]>seeds[i]) dp[i]=dp[i-1]+1; else dp[i]=1; res=Math.max(res,dp[i]); } return res; }
public int lengthOfLIS (int[] seeds) { // write code here int n=seeds.length; if(n<2) return n; int[] dp=new int[n]; Arrays.fill(dp,1); int res=0; for(int i=1;i<n;i++){ for(int j=0;j<i;j++){ //如果j比i大,那就认为dp[i]是以dp[j]为结尾的符合情况的+1 if(seeds[j]>seeds[i]) dp[i]=dp[j]+1; } res=Math.max(res,dp[i]); } return res; }