Java o(nlogn) solution by used hashmap (769 solution is attatched)
769 solution:https://leetcode.com/problems/max-chunks-to-make-sorted/discuss/488014/Java-greedy-sol-100\n\nclass Solution {\n    public int maxChunksToSorted(in
769 solution:https://leetcode.com/problems/max-chunks-to-make-sorted/discuss/488014/Java-greedy-sol-100\n```\nclass Solution {\n    public int maxChunksToSorted(int[] arr) {\n        int sort[]=new int[arr.length];\n        int ans=0;\n        Map<Integer,Integer>map=new HashMap<>();\n        for(int i=0;i<arr.length;i++){\n            sort[i]=arr[i];\n        }\n        Arrays.sort(sort);\n        for(int i=0;i<arr.length;i++){\n            if(map.containsKey(sort[i])){\n                map.put(sort[i],map.get(sort[i])+1);\n            }else{\n                map.put(sort[i],1);\n            }\n            if(map.get(sort[i])==0){\n                map.remove(sort[i]);\n            }\n            \n            int num=arr[i];\n            if(map.containsKey(num)){\n                map.put(num,map.get(num)-1);\n                if(map.get(num)==0){\n                    map.remove(num);\n                }\n            }else{\n                map.put(num,-1);\n            }\n            if(map.size()==0){\n                ans++;\n            }\n            //System.out.println(map);\n        }\n        return ans;\n    }\n}\n```
[]