Easy and Fast Java Solution || Beats 100%
\n\n# Code\n\nclass Solution {\n    public int maxChunksToSorted(int[] arr) {\n        int rightMin[]=new int[arr.length+1];\n        rightMin[arr.length]=Integ
\n\n# Code\n```\nclass Solution {\n    public int maxChunksToSorted(int[] arr) {\n        int rightMin[]=new int[arr.length+1];\n        rightMin[arr.length]=Integer.MAX_VALUE;\n        for(int i=arr.length-1; i>=0; i--){\n            rightMin[i]=Math.min(rightMin[i+1], arr[i]);\n        }\n        int count=0;\n        int leftMax=Integer.MIN_VALUE;\n        for(int i=0; i<arr.length; i++){\n            leftMax=Math.max(leftMax, arr[i]);\n            if(leftMax <= rightMin[i+1]){\n                count++;\n            }\n        }\n        return count;\n    }\n}\n```
['Array', 'Stack', 'Greedy', 'Monotonic Stack', 'Java']