Python solution using dictionary
from collections import defaultdict\nclass Solution:\n\n    def maxChunksToSorted(self, arr: List[int]) -> int:\n        sorted_list = sorted(arr)\n        ans 
from collections import defaultdict\nclass Solution:\n\n    def maxChunksToSorted(self, arr: List[int]) -> int:\n        sorted_list = sorted(arr)\n        ans = 0\n        s1 = defaultdict(int)\n        s2 = defaultdict(int)\n        # if sorted(arr[i:j]) == sorted_list[i:j]\n        # then they must have the same elements and the number of occurences\n        for i in range(len(arr)):\n            s1[arr[i]]+=1\n            s2[sorted_list[i]]+=1\n            if s1==s2:\n                s1 = defaultdict(int)\n                s2 = defaultdict(int)\n                ans+=1\n        return ans
['Python']