leetcode

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

0926.cpp (255B)


      1 class Solution {
      2   public:
      3     int minFlipsMonoIncr(string s) {
      4         int res = 0, num = 0;
      5         for (char c : s)
      6             if (c == '0')
      7                 res = min(num, res + 1);
      8             else
      9                 ++num;
     10         return res;
     11     }
     12 };