C++ Counting
See my latest update in repo LeetCode\n\n## Solution 1. Counting\n\nEach continuous segment of A or B of length cnt has cnt - 2 pieces avaiable for the players 
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n## Solution 1. Counting\n\nEach continuous segment of `A` or `B` of length `cnt` has `cnt - 2` pieces avaiable for the players to pick. We sum these `cnt - 2`s up and Alice wins if her sum is greater.\n\n```cpp\n// OJ: https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/\n// Author: github.com/lzl124631x\n// Time: O(N)\n// Space: O(1)\nclass Solution {\npublic:\n    bool winnerOfGame(string s) {\n        int sum[2] = {};\n        for (int i = 0, N = s.size(); i < N;) {\n            int c = s[i], cnt = 0;\n            while (i < N && c == s[i]) ++i, ++cnt;\n            sum[c - \'A\'] += max(0, cnt - 2);\n        }\n        return sum[0] > sum[1];\n    }\n};\n```
[]