Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int lengthOfLIS(vector<int>& nums) {
- if (nums.size() == 0)
- return 0;
- vector <int> dp (nums.size(), 1);
- int res = 1;
- for (int j = 0 ; j < nums.size(); j++)
- {
- int cur_r = nums[j];
- for (int i = 0 ; i < j ; i++)
- {
- int cur_l = nums[i];
- if (cur_r > cur_l && dp[i] + 1 > dp[j])
- {
- dp[j] ++;
- res = max (res, dp[j]);
- }
- }
- }
- return res ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement