c++ | easy to understand
We are keeping an array (mn) which stores from the back of array min value from last till that point.\nAfter that,we run a loop from the start of original array
We are keeping an array (mn) which stores from the back of array min value from last till that point.\nAfter that,we run a loop from the start of original array to check if the max value till a certain index is less than or equal to the value at array mn at the same index.If true,we increment c.\n```\nclass Solution {\npublic:\n    int maxChunksToSorted(vector<int>& arr) {\n             int n=arr.size();\n    int mn[n];\n    \n        int c=1;\n        mn[n-1]=arr[n-1];\n        for(int i=n-2;i>=0;i--)\n        {\n            if(arr[i]<mn[i+1])\n                mn[i]=arr[i];\n            else\n                mn[i]=mn[i+1];\n        }\n       int mx=arr[0];\n        for(int i=0;i<n-1;i++)\n        {\n                      \n           mx=max(mx,arr[i]);\n            if(mx<=mn[i+1])\n                c++;\n           \n        }\n      \n    return c;\n    }\n};\n```
[]