class Solution {
public:
int lengthOfLIS(vector<int>& nums) {
int n = nums.size();
vector<int> lis;
for (auto a : nums)
{
if (lis.empty())
lis.push_back(a);
else if (a < lis[0])
lis[0] = a;
else if (a > lis.back())
lis.push_back(a);
else
{
}
}
return lis.size();
}
};
There's a bug in the judge system (the posted code are accepted)

I assume the following snippets should be the correct answer. O(NlogN) time,
class Solution { public: int lengthOfLIS(vector<int>& nums) { int n = nums.size(); vector<int> lis; for (auto a : nums) { if (lis.empty()) lis.push_back(a); else if (a < lis[0]) lis[0] = a; else if (a > lis.back()) lis.push_back(a); else { int left = 0; int right = lis.size()  1; while (left <= right) { int mid = left + ((right  left) >> 1); if (lis[mid] == a) { left = mid; break; } else if (lis[mid] > a) right = mid  1; else left = mid + 1; } lis[left] = a; } } return lis.size(); } };