Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int maxChunksToSorted(vector<int>& arr) {
- int maxVal=0, cnt=0;
- for(int i=0; i<arr.size(); i++){
- maxVal = max(maxVal, arr[i]);
- if(maxVal == i)
- cnt++;
- }
- return cnt;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement