leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0769.cpp (286B)


      1 class Solution {
      2   public:
      3     int maxChunksToSorted(const vector<int> &arr) const {
      4         set<int> st;
      5         int res = 0;
      6         for (int i = 0; i < arr.size(); i++) {
      7             st.insert(arr[i]);
      8             if (*st.rbegin() == i) res++;
      9         }
     10         return res;
     11     }
     12 };