c++, Time:O(N), space:O(1) beginner friendly solution
Intuition\nconsider an examples "AA" or "BB" or "A" or "B".From all this example we can understand string length should be greater than or equal to 3.Because wh
# Intuition\nconsider an examples "AA" or "BB" or "A" or "B".From all this example we can understand string length should be greater than or equal to 3.Because when string length is lessthan 3 we cann\'t find 3 consecutive A\'s. \nThis problems is as simple as finding number of 3 consecutive A\'s and \nnumber of 3 consecutive B\'s in given string.\nIf number of A\'s are greater than B\'s return True else return false.\n\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        int n =colors.size();\n        if(n<3)return false;//if size lessthan 3 we cann\'t find 3consecutive A\'s.\n        int a=0;\n        int b=0;\n        for(int i=1;i<n-1;i++){\n            if(colors[i-1]==\'A\' && colors[i]==\'A\' && colors[i+1]==\'A\')a++;//finding number of consecutive A\'s in string.\n            if(colors[i-1]==\'B\' && colors[i]==\'B\' && colors[i+1]==\'B\')b++;//finding number of consecutive B\'s in string.\n        }\n        if(a-b>0)return true; // if number of A\'s is greather than B\'s return true.\n        return false;\n    }\n// if you understand this explaination please upvote.\n};\n```
['String', 'C++']