Advance Sorting Technique
class Solution {\npublic:\n    int maxChunksToSorted(vector& arr)\n    {\n        vector right_min(arr.size()+1,INT_MAX);\n        int count = 0;\n        int l
class Solution {\npublic:\n    int maxChunksToSorted(vector<int>& arr)\n    {\n        vector<int> right_min(arr.size()+1,INT_MAX);\n        int count = 0;\n        int left_max = INT_MIN;\n        for(int i=arr.size()-1;i>=0;i--)\n        {\n            right_min[i] = min(right_min[i+1],arr[i]);\n        }\n        \n        for(int i =0; i<arr.size();i++)\n        {\n            left_max = max(left_max,arr[i]);\n            if(left_max <= right_min[i+1])\n                count +=1;\n        }\n        return count;  \n    }\n};
[]