(动态规划) leetcode 647. Longest Continuous Increasing Subsequence
这道题求连续的最长递增子序列。
思路:
1. 确定状态:
2. 子问题:
3. 状态方程:
4. 初始条件及边界情况:
5. 计算顺序:
class Solution { public: int findLengthOfLCIS(vector<int>& nums) { int n = nums.size(); if(n==0) return 0; int f[n]; int res = 0; for(int i=0; i<n; i++){ f[i] = 1; if(i>0 && nums[i-1]<nums[i]) f[i] = f[i-1]+1; if(f[i] > res) res = f[i]; } return res; } };