2 solutions | Counting & Stack | C++
Counting\n\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        long long cntA = 0, cntB = 0, alice = 0, bob = 0;\n        for(char c : c
# Counting\n```\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        long long cntA = 0, cntB = 0, alice = 0, bob = 0;\n        for(char c : colors) {\n            if(c == \'A\') {\n                cntA++;\n                if(cntA >= 3) alice += cntA - 2;\n                cntB = 0;\n            }\n            else {\n                cntB++;\n                if(cntB >= 3) bob += cntB - 2;\n                cntA = 0;\n            }\n        }\n        return alice > bob;\n    }\n};\n```\n\n# Stack\n```\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        int bob = 0, alice = 0;\n        stack<char> s;\n        for(char c : colors) {\n            if(s.size() >= 2) {\n                char first = s.top(); s.pop();\n                char second = s.top(); s.pop();\n                s.push(second);\n                s.push(first);\n                if(c == first && c == second) {\n                    c == \'A\' ? alice++ : bob++;\n                }\n                else s.push(c);\n            }\n            else s.push(c);\n        }\n        return alice > bob;\n    }\n};\n\n```
['Stack', 'Counting', 'C++']