C++ Solution || Beats 99% || Easy To Understand
Easy To Understand Solution\n\n# Approach: Count\n\n# Intuition\nThere are two very important things to notice about this game  that will allow us to easily sol
# Easy To Understand Solution\n\n# Approach: Count\n\n# Intuition\nThere are two very important things to notice about this game  that will allow us to easily solve the problem:\n\nWhen one player removes a letter, it will never create a new removal opportunity for the other player. For example, let\'s say you had *"ABAA"*. If the *"B"* wasn\'t there, then Alice would have a new removal opportunity. However, the *"B"* can never be removed because of the rules of the game. This observation implies that at the start of the game, all moves are already available to both players.\nThe order in which the removals happen is irrelevant. This is a side effect of the previous observation. Let\'s say there was a section in the middle of the string *"BAAAAAB"*. Alice has three removal choices here, *"BA[A]AAAB"*, *"BAA[A]AAB"*, and *"BAAA[A]AB"*. However, her choice is irrelevant, because all three choices will result in *"BAAAAB"*.\n\n![POD-2.png](https://assets.leetcode.com/users/images/1c109c7c-ba73-4484-b167-ed4f5def41a3_1696228296.0426672.png)\n\n\n# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        int alice=0;\n        int bob=0;\n        for(int i=1;i<colors.size()-1;i++)\n        {\n            if(colors[i-1]==\'A\' && colors[i+1]==\'A\' && colors[i]==\'A\')\n            {\n                alice++;\n            }\n            else if(colors[i-1]==\'B\' && colors[i+1]==\'B\' && colors[i]==\'B\')\n            {\n                bob++;\n            }\n        }\n        cout<<alice<<" "<<bob<<endl;\n        return alice>bob;\n    }\n};\n```\n\n![upvote.jpg](https://assets.leetcode.com/users/images/bff6cb17-e6a2-463b-8ce0-e2e018e06d2f_1696227770.901257.jpeg)\n
['Greedy', 'Game Theory', 'C++']