Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int lengthOfLIS(vector<int>& nums) {
- vector<int> lis;
- for(auto num : nums){
- int pos = lower_bound(lis.begin(), lis.end(), num)-lis.begin();
- if(pos == lis.size())
- lis.push_back(num);
- else
- lis[pos] = num;
- }
- return lis.size();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement