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)


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