```
class Solution {
public:
int lengthOfLIS(vector<int>& nums) {
vector<int> DP;
DP.push_back(INT_MIN);
for(int i=0;i<nums.size();i++)
{
vector<int>::iterator it=lower_bound(DP.begin(),DP.end(),nums[i]);
if(it==DP.end())
{
DP.push_back(nums[i]);
}
else
{
if(*it>nums[i])
{
*it=nums[i];
}
}
}
return DP.size()-1;
}
};
```