class Solution {
public int lengthOfLIS(int[] nums) {
//边界条件
if(nums.length <= 1) return nums.length;
//定义dp[i]表示前nunms[0-i]的最长递增子序列的长度
int[] dp = new int[nums.length];
//初始化
Arrays.fill(dp, 1);
int result = 0;
for(int i = 1; i < nums.length; i++){
for(int j = 0; j < i; j++){
if(nums[i] > nums[j]){
//求最大的dp[i]就是在0-i中找j < i最大的能+1的dp[j]
dp[i] = Math.max(dp[i], dp[j] + 1);
}
}
//保存最大的dp[i]
result = Math.max(dp[i], result);
}
return result;
}
}