[C++] LIS in nlogn solution
Code\n\nclass Solution {\npublic:\n    int LIS(vector<int> &arr){\n        vector<int> sorted;\n\n        sorted.push_back(arr[0]);\n\n        for(int i=1;i<arr
# Code\n```\nclass Solution {\npublic:\n    int LIS(vector<int> &arr){\n        vector<int> sorted;\n\n        sorted.push_back(arr[0]);\n\n        for(int i=1;i<arr.size();i++){\n            if(arr[i] >= sorted.back()){\n                sorted.push_back(arr[i]);\n            }\n            else{\n                int it = upper_bound(sorted.begin(),sorted.end(),arr[i]) - sorted.begin();\n                sorted[it] = arr[i];\n            }\n        }\n        return sorted.size();\n    }\n    int kIncreasing(vector<int>& arr, int k) {\n        int ans = 0;\n        for(int i=0;i<k;i++){\n            vector<int> newArr;\n            for(int j=i;j<arr.size();j+=k){\n                newArr.push_back(arr[j]);\n            }\n            ans += ( newArr.size() - LIS(newArr));\n        }\n        return ans;\n    }\n};\n```
['C++']