版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013554860/article/details/86730851
https://leetcode.com/problems/max-chunks-to-make-sorted/
class Solution {
public:
int maxChunksToSorted(vector<int>& arr) {
int res = 0, len = arr.size(), mx = 0;
for(int i=0; i<len; i++){
mx = max(mx, arr[i]);
if(mx==i) res+=1;
}
return res;
}
};