Simple 10 line C++ O(N) Solution!
IntuitionJust sort the array and compare the prefix sums at each index!Complexity
Time complexity: O(N)
Space complexity: O(1)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Just sort the array and compare the prefix sums at each index!

# Complexity
- Time complexity: O(N)
- Space complexity: O(1)

# Code
```cpp []
class Solution {
public:
    int maxChunksToSorted(vector<int>& arr) {
        vector<int> nums = arr;
        sort(nums.begin(),nums.end());
        int n = arr.size();
        long long int s = 0,s2 = 0,ans = 0;
        for(int i=0;i<n;i++){
            s+=nums[i];
            s2+=arr[i];
            if(s==s2)ans++;
        }
        return ans;
    }
};
```
['C++']