C++ 7 lines, O (n * log n) / O(n)
Same as Max Chunks To Make Sorted (ver. 1). We just need to normalize the input array so it contains the indexes. We use the sorting for the normalization, and 
Same as [Max Chunks To Make Sorted (ver. 1)](https://discuss.leetcode.com/topic/117837/c-4-lines-o-n-o-1). We just need to normalize the input array so it contains the indexes. We use the sorting for the normalization, and one trick here is to have a stable sort, so that if we have the same value, the index will be lowest for the value appearing first.\n```\nint maxChunksToSorted(vector<int>& v) {\n    vector<int> arr(v.size());\n    iota(arr.begin(), arr.end(), 0);\n    sort(arr.begin(), arr.end(), [&v](int i1, int i2) {return v[i1] == v[i2] ? i1 < i2 : v[i1] < v[i2]; });\n\n    for (auto i = 0, max_i = 0, ch = 0; i <= arr.size(); ++i) {\n      if (i == arr.size()) return ch;\n      max_i = max(max_i, arr[i]);\n      if (max_i == i) ++ch;\n    }\n}\n```
[]