Precise Python Stack 7 lines solution with explanation
python\nclass Solution:\n    def maxChunksToSorted(self, arr: List[int]) -> int:\n        stack = [] # store a list of biggest element of each chunk\n        fo
```python\nclass Solution:\n    def maxChunksToSorted(self, arr: List[int]) -> int:\n        stack = [] # store a list of biggest element of each chunk\n        for n in arr:\n            m = n # the biggest element from beginning to n\n            while len(stack)>0 and stack[-1]>n:\n                m = max(m, stack.pop())\n            stack.append(m)  # all element bigger than n was poped out of stack, so this is the biggest element\n        return len(stack) # length of the chunks array\n```\n\nBecause no element will be visited over twice, this is a linear time complexity algorithm.
[]