C++, O(nlogn), Neat & Clean


#1
int Solution::lis(const vector<int> &a) {
    int n = a.size();
    vector<int> dp(n+1, INT_MAX);
    dp[0] = INT_MIN;
    
    for(int i=0; i < n; i++){
        *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }
    int i;
    for(i=0;i <= n;i++){
        if(dp[i] == INT_MAX) break;
    }
    return i-1;
}