0300.Longest Increasing Subsequence
class Solution {
public:
int lengthOfLIS(vector<int>& nums) {
int n = nums.size();
if(n == 1) return 1;
int result = 0;
// dp[i]: max length end at i
vector<int> dp(n, 1);
for(int i = 0; i < nums.size(); i++) {
for(int j = 0; j < i; j++) {
if(nums[i] > nums[j]) {
dp[i] = max(dp[i], dp[j] + 1);
}
}
result = max(result, dp[i]);
}
return result;
}
};