🔥🔥🔥Easiest Approach || O(n)  time and O(1) space || beginner friendly solution 🔥🔥🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nTry to think as subarray problem having length >= 3.\n\n# Approach\n Describe your appr
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTry to think as subarray problem having length >= 3.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nTake all the subarrays of A and B having length greater than or equal to 3 and store them into a final variable (totalA, totalB here in code) by subracting 2 from count sofar as 3 will give 1, 4 will give you 2, 5 will give 3 and so on.\nAnd these are the all possiblities of removing.\nIf final count of A\'s possiblities is less than or equal to count of B\' possiblities then return false according to question else return true.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity of the code is O(n), where n is the length of the input string colors. This is because there is a single loop that iterates through each character of the string once.\n\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity is O(1), constant space.\n\n# Code\n```\nclass Solution {\npublic:\n    bool maxiAB(string colors) {\n        int totalA=0, cur_maxA=0, cur_maxB=0, totalB=0;\n        for(int i=0;i<colors.size();i++) {\n            if(colors[i] == \'A\')cur_maxA++;\n            if(i == colors.size()-1 || colors[i]==\'B\') {\n                if(cur_maxA >= 3)totalA += cur_maxA-2;\n                cur_maxA=0;\n            }\n\n            if(colors[i] == \'B\')cur_maxB++;\n            if(i == colors.size()-1 || colors[i]==\'A\') {\n                if(cur_maxB >= 3)totalB += cur_maxB-2;\n                cur_maxB=0;\n            }\n        }\n        return totalA<=totalB ? false : true;\n    }\n\n    bool winnerOfGame(string colors) {\n        return maxiAB(colors);\n    }\n};\n```
['C++']