C++ || EXPLAINED || CLEAN CODE ||
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution{\npublic:\n    int LIS(vector<int>& A){\n        vector<int> temp;\n        temp.push_back(A[0]);\n        for(int i=1;i<A.size();i++){\n            if(A[i]>=temp.back()){\n                temp.push_back(A[i]);\n            }\n            else{\n                int lo=0,hi=temp.size()-1,idx;\n                while(hi>=lo){\n                    int m=lo+(hi-lo)/2;\n                    if(temp[m]>A[i]){\n                        idx=m;\n                        hi=m-1;\n                    }\n                    else lo=m+1;\n                }\n                temp[idx]=A[i];\n            }\n        }\n        return temp.size();\n    }\n    int kIncreasing(vector<int>& arr,int k){\n        int val=0;\n        // arr=[2,2,2,2,2,1,1,4,4,3,3,3,3,3]   k=1\n        // k=1 means we need to make our array like this=>\n        // arr[0]<=arr[0+k]<=arr[0+k+k]<=arr[0+k+k+k]......\n        // arr[0]<=arr[1]<=arr[2]......\n        // But as we can see 1,1,4,4 is will not let that happen.\n        // So we will perform the given operation to change their\n        // values to anything we want.\n        // Obviously we will make it=>\n        // [2,2,2,2,2,*2,*2,*3,*3,3,3,3,3,3]\n        // But how will we make sure what number of elements should we \n        // change as we need the min number of operation.\n        // The answer is => Whichever element is not contributing to\n        // the longest increasing subsequence.\n        // So we will calculate the LIS for arr which is=>\n        // [2,2,2,2,2,3,3,3,3,3] length of lonest inc subsequece=10\n        // Now our answer is arr.length()-length of longest inc subseq\n        // 14-10=4\n        // But if k!=1 then=>\n        // [2,4,1,5,7,8]  k=2\n        // Now calculate LIS for [2,1,7] and [4,5,8] seperately.\n        // For [2,1,7] => LIS=2 => So we need to change 3-2=1 elements\n        // For [4,5,8] => LIS=3 => So we need to change 3-3=0 elements\n        // So our answer is 1+0=1\n        for(int i=0;i<k;i++){\n            vector<int> temp;\n            for(int j=i;j<arr.size();j+=k){\n                temp.push_back(arr[j]);\n            }\n            val+=LIS(temp);\n        }\n        return arr.size()-val;\n    }\n};\n```
['C++']