https://leetcode.com/problems/longest-increasing-subsequence/
배열에서 존재하는 가장 긴 increasing subsequence 의 길이
public int lengthOfLIS(int[] nums) {
int n = nums.length;
int[] dp = new int[n];
Arrays.fill(dp, 1);
int answer = 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (nums[j] < nums[i]) {
dp[i] = Math.max(dp[i], dp[j] + 1);
}
}
answer = Math.max(answer, dp[i]);
}
return answer;
}
dp[i] = nums[i] 를 마지막 원소로 사용하는 가장 긴 증가 부분 수열의 길이
dp[i] = max(dp[i], dp[j] + 1)