C++ solution using chaining technique
\n\nclass Solution {\npublic:\n    int maxChunksToSorted(vector<int>& arr) {\n        \n        vector<int> rmin(arr.size() + 1);\n        \n        int val = I
```\n\nclass Solution {\npublic:\n    int maxChunksToSorted(vector<int>& arr) {\n        \n        vector<int> rmin(arr.size() + 1);\n        \n        int val = INT_MAX;\n        rmin[arr.size()] = val;\n        for(int i = arr.size() - 1; i >= 0; i--) {\n            val = min(val, arr[i]);\n            rmin[i] = val;\n        }\n        \n        int lmax = arr[0];\n        int count = 0;\n        for(int i = 0; i < arr.size(); i++) {\n            lmax = max(lmax, arr[i]);\n            \n            if(lmax <= rmin[i + 1])\n                count++;\n        }\n        \n        return count;\n    }\n};\n\n```
['C', 'C++']