Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. int lengthOfLIS(vector<int>& nums) {
  2.         vector<int> last_indices;
  3.        
  4.         for (int i = 0; i < nums.size(); ++i) {
  5.             auto first_greater_or_eq = lower_bound(last_indices.begin(), last_indices.end(), nums[i]);
  6.             if (first_greater_or_eq == last_indices.end()) last_indices.push_back(nums[i]);
  7.             else *first_greater_or_eq = nums[i];
  8.         }
  9.        
  10.         return last_indices.size();
  11.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement