C++ | LIS(MODIFIED) | IMPLEMENTATION
PLEASE UPVOTE IF U LIKE MY SOLUTION AND EXPLANATION\n\nclass Solution {\npublic:\n    int kIncreasing(vector<int>& arr, int k) {\n        \n        int n=arr.si
**PLEASE UPVOTE IF U LIKE MY SOLUTION AND EXPLANATION**\n```\nclass Solution {\npublic:\n    int kIncreasing(vector<int>& arr, int k) {\n        \n        int n=arr.size();\n        \n        //we consider a visited array so let say for i we traverse i+k,i+2*k,i+3*k,...\n        //we do not need to consider doing operations for them again.\n        vector<bool>vis(n,0);\n        \n        //total operations to make a {i+j*k} where j*k<n non-decreasing\n        int Noperations=0;\n        for(int i=0;i<n;i++)\n        {\n            //we only consider when the element is not visited previously\n            if(!vis[i])\n            {\n                //we perform the O(nlogn) approach of LIS but with some modification\n                //as we want a non-decreasing sequence so repetition of element is allowed\n                //in the LIS array\n                vector<int>LIS;\n                for(int j=i;j<n;j+=k)\n                {\n                    if(LIS.empty()||LIS.back()<=arr[j])\n                        LIS.push_back(arr[j]);\n                    else\n                    {\n                        int idx=upper_bound(LIS.begin(),LIS.end(),arr[j])-LIS.begin();\n                        LIS[idx]=arr[j];\n                    }\n                    //we mark the processed element as visited\n                    vis[j]=1;\n                }\n                //this is the count of elements which are in non-decreasing fashion\n                //so we do not perform operations for Noperations elements\n                Noperations+=LIS.size();\n            }\n        }\n        //we have to perform operation for the remaining elements\n        return n-Noperations;\n    }\n};\n```
[]