2111. Minimum Operations to Make the Array K-Increasing
LNDS (Longest Non-Decreasing Subarray) Approach\n\nclass Solution {\n    public int upperBound(ArrayList<Integer> a, int val){\n        int l=0;int r=a.size()-1
LNDS (Longest Non-Decreasing Subarray) Approach\n```\nclass Solution {\n    public int upperBound(ArrayList<Integer> a, int val){\n        int l=0;int r=a.size()-1;\n        while(l<r){\n            int m=(l+r)/2;\n            if(a.get(m)<=val){\n                l=m+1;\n            }\n            else{\n                r=m;\n            }\n        }\n        return l;\n    }\n    public int lnds(ArrayList<Integer> arr){\n        ArrayList<Integer> temp=new ArrayList<>();\n        int n = arr.size();\n        for(int i=0;i<n;i++){\n            if(temp.size()==0 || temp.get(temp.size()-1)<=arr.get(i)){\n                temp.add(arr.get(i));\n            }\n            else{\n                int ind=upperBound(temp,arr.get(i));\n                temp.set(ind, arr.get(i));\n            }\n        }\n        return temp.size();\n    }\n    public int kIncreasing(int[] arr, int k) {\n        int minchanges=0;\n        for(int i=0;i<k;i++){\n            ArrayList<Integer> subarr=new ArrayList<>();\n            for(int j=i;j<arr.length;j+=k){\n                subarr.add(arr[j]);\n            }\n            minchanges+=subarr.size()-lnds(subarr);\n        }\n        return minchanges;\n    }\n}\n```
['Array', 'Binary Tree', 'Java']