O(n) Java
No difference between ver1 or 2. \n\n    public int maxChunksToSorted(int[] arr) {\n        \n        int S = arr.length;       \n        int[] max = new int[S]
No difference between ver1 or 2. \n````\n    public int maxChunksToSorted(int[] arr) {\n        \n        int S = arr.length;       \n        int[] max = new int[S];\n        int[] min = new int[S];\n        \n        max[0] = arr[0];\n        for (int i=1; i<S; i++)\n            max[i] = Math.max(max[i-1], arr[i]);\n        \n        min[S-1] = arr[S-1];\n        for (int i=S-2; i>=0; i--)\n            min[i] = Math.min(min[i+1], arr[i]);\n        \n        int res = 0; \n        for (int i=0; i<S-1; i++)\n            if (max[i] <= min[i+1])\n                res++; \n        \n        return res+1;\n    }\n````
[]