Created
June 15, 2021 08:58
-
-
Save saswata-dutta/23d699e529b5094325b4b9019a62f25c to your computer and use it in GitHub Desktop.
find len of LIS using patience sort like piles
This file contains hidden or 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
int lengthOfLIS(vector<int>& nums) { | |
vector<int> piles; | |
for(auto i: nums) { | |
auto it = std::lower_bound(piles.begin(), piles.end(), i); | |
if(it==piles.end()) piles.push_back(i); | |
else *it = i; | |
} | |
return piles.size(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment