Efficient || Faster || Optimized Solution || Easy to understand code || O(n) time complexity :)
Intuition\n<-- To count the number of valid moves Alice and Bob can make based on the given rules and determine the winner based on who can make more valid move
# Intuition\n<-- To count the number of valid moves Alice and Bob can make based on the given rules and determine the winner based on who can make more valid moves.\n\n# Approach\n1. Initialize counters for Alice\'s and Bob\'s valid moves.\n2. Iterate through the string, checking for consecutive \'A\'s and \'B\'s.\n3. Increment the respective counter for each valid move.\n4. Determine the winner by comparing the counters.\n\n# Complexity\nTime complexity: O(n) as we iterate through the string once.\nSpace complexity: O(1) as we use a constant amount of extra space.\n\n# Code\n```\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        int count1=0,c2=0;\n        for(int i=1;i<colors.size()-1;i++){\n            if(colors[i]==\'A\' && colors[i-1]==\'A\' && colors[i+1]==\'A\' ){\n               count1++;\n            }\n            else if(colors[i]==\'B\' && colors[i-1]==\'B\' && colors[i+1]==\'B\' ){\n                c2++;\n            }      \n        }\n        return count1>c2;\n    }\n};\n```
['Counting', 'C++']