leetcode

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

1758.cpp (270B)


      1 class Solution {
      2   public:
      3     int minOperations(const string &s) const {
      4         int num = 0, crnt = 1;
      5         for (const char c : s) {
      6             if ((c & 0xF) != crnt) num++;
      7             crnt = !crnt;
      8         }
      9         return min(num, (int)size(s) - num);
     10     }
     11 };