C++ Solutions, with small explanation,
\nclass Solution {\npublic:\n    int maxChunksToSorted(vector<int>& a) {\n        int n = a.size();\n        if(n < 2) return 1;\n        /*\n        \n        
```\nclass Solution {\npublic:\n    int maxChunksToSorted(vector<int>& a) {\n        int n = a.size();\n        if(n < 2) return 1;\n        /*\n        \n            after sorting the array should look like this:\n            \n            .....Max1 | Min2..........Max2 | Min3.........Max3 | Min4 ........... Max4|\n            so Max1 <= Min2 , Max2 <= Min3 .... Max(n - 1) <= Min(n)\n            \n            so we just need to count them\n        \n        */\n        \n        vector<int> minR(n);\n        vector<int> maxL(n);\n        \n        minR[n - 1] = a[n - 1];\n        for(int i = n - 2; i >= 0; i--) minR[i] = min(minR[i + 1], a[i]);\n        \n        maxL[0] = a[0];\n        for(int i = 1; i < n; i++) maxL[i] = max(maxL[i - 1], a[i]);\n        \n        int partitions = 0;\n        for(int i = 0; i < n - 1; i++)  {\n            if(maxL[i] <= minR[i + 1]) partitions++;\n        }\n        \n        int ans = partitions + 1;\n        return ans;\n    }\n};\n```
[]