Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int lengthOfLIS(vector<int>& nums) {
- vector<int> last_indices;
- for (int i = 0; i < nums.size(); ++i) {
- auto first_greater_or_eq = lower_bound(last_indices.begin(), last_indices.end(), nums[i]);
- if (first_greater_or_eq == last_indices.end()) last_indices.push_back(nums[i]);
- else *first_greater_or_eq = nums[i];
- }
- return last_indices.size();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement