Cpp Solution O(n) || Simple Solution
Intuition\nCount the Number of "AAA" and "BBB"\n\n# Approach\n-> Count number of "AAA" and "BBB" and store them in a variable\n\n-> If count of "AAA" is more th
# Intuition\nCount the Number of "AAA" and "BBB"\n\n# Approach\n-> Count number of "AAA" and "BBB" and store them in a variable\n\n-> If count of "AAA" is more than "BBB" than than Alice wins otherwise Bob wins Why?\n\n> If count of "AAA" is less than "BBB" than Bob have more pieces to remove, and if count of both "AAA","BBB" are same(or both are zero) than on Alice will the first one to start and on her turn she couldn\'t remove a piece therefore she will be the one to lose.\n\n# Complexity\n- Time complexity: O(n), 84.69% better than Cpp online submissions\n\n- Space complexity:O(1), 79.53% better than Cpp online submissions\n\n# Code\n```\nclass Solution {\npublic:\n    bool winnerOfGame(string c) {\n        if(c.size()==2)\n         return false;\n        int a=0,b=0;\n        for(int i=1;i<c.size()-1;i++)\n        {\n            if(c[i]==\'A\' && c[i-1]==\'A\' && c[i+1]==\'A\')\n            {\n                a++;\n            } \n            else if(c[i]==\'B\' && c[i-1]==\'B\' && c[i+1]==\'B\')\n             {\n                b++;\n             }\n        }\n        if(a==b || a<b)\n        return false;\n        else\n        return true;\n    }\n};\n```
['Math', 'String', 'C', 'Counting', 'C++']