Advertisement
RaFiN_

LIS small codes

Dec 25th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. int lengthOfLIS(vector<int>& nums) {
  2.     vector<int> res;
  3.     for(int i=0; i<nums.size(); i++) {
  4.         auto it = std::lower_bound(res.begin(), res.end(), nums[i]);
  5.         if(it==res.end()) res.push_back(nums[i]);
  6.         else *it = nums[i];
  7.     }
  8.     return res.size();
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement