Easy C++ O(n) solution
Please upvote if you like it\n\nclass Solution {\npublic:\n    int maxChunksToSorted(vector<int>& arr) {\n       //generate right min\n        int n=arr.size();
**Please upvote if you like it**\n```\nclass Solution {\npublic:\n    int maxChunksToSorted(vector<int>& arr) {\n       //generate right min\n        int n=arr.size();\n        int rightMin[n+1];\n        rightMin[n]=INT_MAX;\n        for(int i=n-1;i>=0;i--)\n        {\n            rightMin[i]=min(rightMin[i+1],arr[i]);\n            \n        }\n\t\t\n        int leftMax=INT_MIN;\n        int count=0;\n\t\t//iterate an array and manage left max as well as count chunks\n        for(int i=0;i<n;i++)\n        {\n            leftMax=max(leftMax,arr[i]);\n            if(leftMax<=rightMin[i+1])\n            {\n                count++;\n            }\n        }\n        return count;\n    }\n};\n```
[]