Python left max & right min O(N) time & space
\n    def maxChunksToSorted(self, arr: List[int]) -> int:\n        import math\n        right_min = [math.inf] * len(arr)\n        left_max = arr.copy()\n      
```\n    def maxChunksToSorted(self, arr: List[int]) -> int:\n        import math\n        right_min = [math.inf] * len(arr)\n        left_max = arr.copy()\n        for i in range(len(arr) - 2, -1, -1):\n            right_min[i] = min(arr[i + 1], right_min[i + 1])\n        for i in range(1, len(arr)):\n            left_max[i] = max(left_max[i - 1], arr[i])\n        chunks = 0\n        for i in range(len(arr)):\n            if right_min[i] >= left_max[i]:\n                chunks += 1\n        return chunks\n\n```
[]