O(n) Time | Count consecutive AAAs & BBBs
\nC++\n\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        int cntA=0,cntB=0;\n        for(int i=1;i<colors.size()-1;i++){\n\t\t\t// Co
\n***C++***\n```\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        int cntA=0,cntB=0;\n        for(int i=1;i<colors.size()-1;i++){\n\t\t\t// Count of Consecutive \'AAA\'s which Alice can remove\n            if(colors[i]==\'A\'&&colors[i-1]==\'A\'&&colors[i+1]==\'A\')cntA++;\n\t\t\t\n\t\t\t// Count of Consecutive \'BBB\'s which Bob can remove\n            if(colors[i]==\'B\'&&colors[i-1]==\'B\'&&colors[i+1]==\'B\')cntB++;\n        }\n\t\t\n\t\t// Alice wins if she can remove more \'AAA\'s than Bob can remove \'BBB\'s\n        return cntA>cntB;\n    }\n};\n```\n\n***Java***\n```\nclass Solution {\n    public boolean winnerOfGame(String colors) {\n        int cntA=0,cntB=0;\n        for(int i=1;i<colors.length()-1;i++){\n             if(colors.charAt(i)==\'A\'&&colors.charAt(i-1)==\'A\'&&colors.charAt(i+1)==\'A\')cntA++;\t\t\t\n            if(colors.charAt(i)==\'B\'&&colors.charAt(i-1)==\'B\'&&colors.charAt(i+1)==\'B\')cntB++;\n        }\n        \n        return cntA>cntB;\n    }\n}\n```
['C', 'Java']