C++ easy-to-understand solution
What we have to do is to look how far an element is from its position in the sorted array. Accordingly we decide. If in a range of array the sum of displacement
What we have to do is to look how far an element is from its position in the sorted array. Accordingly we decide. If in a range of array the sum of displacement of elements from initial position is 0 then we can make them in a chunk.\n\n```\n    static bool compare(pair<int,int> p1,pair<int,int> p2)\n{\n    if(p1.first!=p2.first){return p1.first<p2.first;}\n    return p1.second<p2.second;\n}\n\nint maxChunksToSorted(vector<int>& arr) \n{\n    vector<pair<int,int> > a;\n    for(int i=0;i<arr.size();i++)\n    {\n        a.push_back({arr[i],i});\n    }\n    sort(a.begin(),a.end(),compare);\n    \n    int ans=0;\n    int sum=0;\n    for(int i=0;i<a.size();i++)\n    {\n        sum+=(i-a[i].second);\n        if(sum==0)\n        {ans++;}\n    }\n    return ans;\n}\n```
['C', 'Sorting']