Advertisement
nikunjsoni

769

Jun 29th, 2021
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int maxChunksToSorted(vector<int>& arr) {
  4.         int maxVal=0, cnt=0;
  5.         for(int i=0; i<arr.size(); i++){
  6.             maxVal = max(maxVal, arr[i]);
  7.             if(maxVal == i)
  8.                 cnt++;
  9.         }
  10.         return cnt;
  11.     }
  12. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement