leetcode

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

2380.cpp (330B)


      1 class Solution {
      2   public:
      3     int secondsToRemoveOccurrences(const string &s) const {
      4         int res = 0, count = 0;
      5 
      6         for (int i = 0; i < s.size(); ++i) {
      7             if (s[i] == '0')
      8                 count++;
      9             else if (count)
     10                 res = max(res + 1, count);
     11         }
     12 
     13         return res;
     14     }
     15 };