class Solution {
public:
int maxChunksToSorted(vector<int>& arr) {
int loop;
int cnt = 0;
int max = 0;
int right = arr[0];
for (loop = 0; loop != arr.size(); loop++) {
right = fmax(right, arr[loop]);
if (loop == right) {
cnt++;
}
}
return cnt;
}
};