Simple & Intuitive O(n) Java Solution.
Intuition\nA grouping of AAA means that Alice can remove one color. So a grouping of AAAA would mean that Alice can remove 2 colors. A grouping of AAAAA would m
# Intuition\nA grouping of AAA means that Alice can remove one color. So a grouping of AAAA would mean that Alice can remove 2 colors. A grouping of AAAAA would mean that Alice can remove 3 colors, and so on. Notice how that number keeps going up. We should keep track of it somehow! Whoever can remove the most colors, will win the game eventually. Thus if we can devise an algorithm to keep track of this number of A\'s or B\'s such that AAA would be 1 and AAAA would return 2, and so on, we can calculate if A > B, Alice wins, if A < B, Bob wins, and if A = B, Bob wins.\n\n# Approach\nCreate an algorithm that will take in two parameters ```(String colors, char target)```, where colors is the colors String given and target is either A or B. Within this algorithm, you must look for the target within your string. While iterating through the string, if the current character matches the target, you need to increment a counter. If the current character does not match the target, set the counter to 0. This simulates having to start all over if you reach a character that doesn\'t match the target. In this case, you\'d want to start counting over again. Now, if the counter at any point is greater than or equal to 3, then you will want to increment another counter aka ```result```that keeps track of the amount of letters that a player may remove.\n\n# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\n    public boolean winnerOfGame(String colors) {\n        int a = getLetterFrequency(colors, \'A\');\n        int b = getLetterFrequency(colors, \'B\');\n\n        if (a > b) {\n            return true;\n        } else if (a < b) {\n            return false;\n        } else {\n            return false;\n        }\n    }\n\n    private int getLetterFrequency(String colors, char target) {\n        int counter = 0;\n        int result = 0;\n\n        for (int i = 0; i < colors.length(); i++) {\n            char color = colors.charAt(i);\n\n            if (color == target) {\n                counter++;\n            } else {\n                counter = 0;\n            }\n            if (counter >= 3) {\n                result++;\n            }\n        }\n        return result;\n    }\n}\n\n```
['Java']