nikunjsoni

769

Jun 29th, 2021
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. };
RAW Paste Data