C++ || Longest increasing subsequence variation
Goal : to find the minimum numbers of operations to make this array k-increasing.\nApproach: find the minimum numbers of operation of each increasing subsequenc
Goal : to find the minimum numbers of operations to make this array k-increasing.\nApproach: find the minimum numbers of operation of each increasing subsequence( formed by arr[i] -> arr[i+k] -> arr[i+2k] -> ...  where 0<=i<k ) and add them up.\n\nFinding the minimum operations: if we find the longest non-decreasing subsequence of that particular array.\n                                                      then the elements which are not the part of this subsequence are the one whose\n\t\t\t\t\t\t\t\t\t\t\t\t\t  value is to be changed i.e. the minimum numbers of operations.\n\t\t\t\t\t\t\t\t\t\t\t\t\t  \n\t\t\t\t\tminimum no. of operations = size of the array  -   size of longest non decreasing subsequence\n\n```\nclass Solution {\npublic:\n    int minOperation(vector<int> v)\n    {\n        vector<int> lis;  // creating a longest non decreasing subsequence\n        lis.push_back(v[0]);  // adding first element into the array\n        for(int i=1;i<v.size();i++)\n        {\n            if(lis.back()<=v[i])  // if the last element is smaller than the current element\n                lis.push_back(v[i]);  // add it to the array\n            else {\n\t\t\t   // if the last element is larger \n\t\t\t   // then we find the position of the current element \n\t\t\t   // and assign this value to that position \n\t\t\t   // in this way we are are constructing the largest subsequence of non-decreasing elements.\n                int index=upper_bound(lis.begin(),lis.end(),v[i])-lis.begin();  \n                lis[index]=v[i];\n            }\n        }\n        return v.size()-lis.size();\n    }\n    int kIncreasing(vector<int>& arr, int k) {\n         if(k==arr.size())   // if the value of k is equal to the size of array then\n            return 0;          // it is already k-increasing\n        int n=arr.size();\n        int result=0;\n        for(int i=0;i<k;i++)\n        {\n            vector<int> v;   // creating array for every subsequence that needs to be checked for min. no. of operations.\n           for(int j=i;j<n;j+=k)\n              v.push_back(arr[j]);   \n\t\t\t  // here minOperation function will find the minimum no. of operations of a particular array.\n           result=result+minOperation(v); // adding result of each one \n        }\n        return result;\n    }\n};\n```
['C']