Beats 100.00% || Used PrefixMax And SuffixMin Array || Very Easy Solution || C++
Complexity -:

Time complexity -: O(n)


Space complexity -: O(n)

Code -:


# Complexity -: 
- Time complexity -: O(n)

- Space complexity -: O(n)

# Code -: 
```cpp []
class Solution { // prefixMax, suffixMin -: 
public:
    int maxChunksToSorted(vector<int>& arr) {
        int n=arr.size(); 

        // find the prefix Max array 
        vector<int>pre(n); 
        pre[0]=arr[0];
        for(int i=1; i<n; i++){
            pre[i]=max(arr[i], pre[i-1]);
        }

        // find the suffix min array 
        vector<int>suf(n);  
        suf[n-1]=arr[n-1];
        for(int i=n-2; i>=0; i--){
            suf[i]=min(arr[i], suf[i+1]); 
        }

        // apply condition -: 
        int count=1; 
        for(int i=1; i<n; i++){
            if(suf[i]>=pre[i-1]){
                count++;
            }
        }
        return count; 
    }
};
```
['Array', 'Greedy', 'Sorting', 'C++']