Max Chunks To make sorted II
Here we are using chaining technique but slight a different version of it. Firstly we have created a right min array which will store min element from right. Th
Here we are using chaining technique but slight a different version of it. Firstly we have created a right min array which will store min element from right. Then we will generate left max array storing left max. While traversing whenever we encounterd a point where leftmax element becomes less than minimum of right max array. We will count it as a chunk and increment the value of count. We will keep doing this until array.length! \n```\nclass Solution {\n    public int maxChunksToSorted(int[] arr) {\n        //Form right min array\n        int rmin[]=new int[arr.length+1];\n        rmin[arr.length]=Integer.MAX_VALUE;\n        for(int i=arr.length-1;i>=0;i--){\n            rmin[i]=Math.min(rmin[i+1],arr[i]);\n        }\n        \n        //Generating left max array and keeping track of count\n        int lmax=Integer.MIN_VALUE;\n        int c=0;\n        for(int i=0;i<arr.length;i++){\n            lmax=Math.max(lmax,arr[i]);\n            if(lmax<=rmin[i+1])\n                c++;\n        }\n        return c;\n    }\n    \n}\n```
['Java']