C++ O(n) very easy solution,9 ms
we will maintain left max till i & right min till i+1,if(rmin[i]>=lmax[i]||i==arr.size()-1)ans++;  \n\nclass Solution {\npublic:\n    int maxChunksToSorted(vect
#  **we will maintain left max till i & right min till i+1,if(rmin[i]>=lmax[i]||i==arr.size()-1)ans++;  \n```\nclass Solution {\npublic:\n    int maxChunksToSorted(vector<int>& arr) {\n        int ans=0;\n        vector<int>lmax=arr;\n        vector<int>rmin=arr;\n        int maxi=INT_MIN;\n        int mini=INT_MAX;\n        for(int i=arr.size()-2;i>=0;i--){\n            mini=min(arr[i+1],mini);\n            rmin[i]=mini; \n        }\n        for(int i=0;i<arr.size();i++){\n            maxi=max(maxi,arr[i]);\n            lmax[i]=maxi;\n        }\n        for(int i=0;i<arr.size();i++){\n            if(rmin[i]>=lmax[i]||i==arr.size()-1)ans++;            \n        }\n        return ans;\n    }\n};\n```\n# ***pls upvote this solution ,feel free to ask in comments
[]