Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Created June 15, 2021 08:58
Show Gist options
  • Save saswata-dutta/23d699e529b5094325b4b9019a62f25c to your computer and use it in GitHub Desktop.
Save saswata-dutta/23d699e529b5094325b4b9019a62f25c to your computer and use it in GitHub Desktop.
find len of LIS using patience sort like piles
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