Created
May 13, 2024 20:43
-
-
Save SuryaPratapK/cc68e388e8a9b8932fd82fd47028af7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int lengthOfLIS(vector<int>& nums) { | |
int n=nums.size(); | |
vector<int> lis; | |
for(int i=0;i<n;++i){ | |
int lb = lower_bound(lis.begin(),lis.end(),nums[i])-lis.begin(); | |
if(lb==lis.size()) | |
lis.push_back(nums[i]); | |
else | |
lis[lb] = nums[i]; | |
} | |
return lis.size(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment