💯Faster✅💯Lesser✅Efficient🔥Simple🔥Time Complexity O(n)🚀
\uD83D\uDE80 Hi, I\'m Mohammed Raziullah Ansari, and I\'m excited to share multiple ways  to solve this question with detailed explanation of each approach:\n\n
# \uD83D\uDE80 Hi, I\'m [Mohammed Raziullah Ansari](https://leetcode.com/Mohammed_Raziullah_Ansari/), and I\'m excited to share multiple ways  to solve this question with detailed explanation of each approach:\n\n# Problem Explaination: \nThe problem here involves a sequence of colored pieces arranged in a linear order, such as an array or a linked list. Each piece has a specific color. The objective is to remove pieces from this sequence when both of their neighboring pieces have the same color.\n\n\n\n# Problem Approach: \n\n- Initialize two integer variables, count_A and count_B, to zero.\n- Loop through the input string colors from index 1 to len(colors) - 2. This loop iterates through the string, excluding the first and last characters because it checks for consecutive triples.\n- Inside the loop, check if the character at the current index i and the characters at i - 1 and i + 1 are all the same. If they are, it indicates a consecutive triple of the same character.\n- If a triple is found, check the character at index i. If it\'s \'A\', increment count_A by 1. If it\'s \'B\', increment count_B by 1.\n- After the loop, compare count_A and count_B to determine the winner.\n- Return true if count_A is greater than count_B, indicating that player A wins; otherwise, return false.\n# Complexity\n- \u23F1\uFE0F Time Complexity: O(n), where \'n\' is the length of the input string colors.\n\n- \uD83D\uDE80 Space Complexity: O(1) - constant space is used.\n\n# Code\n```Python []\nclass Solution:\n    def winnerOfGame(self, colors: str) -> bool:\n        count_A = 0\n        count_B = 0\n        for i in range(1, len(colors) - 1):\n            if colors[i - 1] == colors[i] == colors[i + 1]:\n                if colors[i] == \'A\':\n                    count_A += 1\n                else:\n                    count_B += 1\n        return count_A > count_B\n\n```\n```Java []\npublic class Solution {\n    public boolean winnerOfGame(String colors) {\n        int countA = 0;\n        int countB = 0;\n        for (int i = 1; i < colors.length() - 1; i++) {\n            if (colors.charAt(i - 1) == colors.charAt(i) && colors.charAt(i) == colors.charAt(i + 1)) {\n                if (colors.charAt(i) == \'A\') {\n                    countA++;\n                } else {\n                    countB++;\n                }\n            }\n        }\n        return countA > countB;\n    }\n}\n\n```\n```C++ []\nclass Solution {\npublic:\n    bool winnerOfGame(string colors) {\n        int countA = 0, countB = 0;\n        int n = colors.length();\n        for (int i = 0; i < n - 2; i++) {\n            if (colors[i] == \'A\' && colors[i + 1] == \'A\' && colors[i + 2] == \'A\') {\n                countA++;\n            }\n            if (colors[i] == \'B\' && colors[i + 1] == \'B\' && colors[i + 2] == \'B\') {\n                countB++;\n            }\n        }\n        return countA > countB;\n    }\n};\n\n```\n```C []\nbool winnerOfGame(char *colors) {\n    int count_A = 0;\n    int count_B = 0;\n    for (int i = 1; i < strlen(colors) - 1; i++) {\n        if (colors[i - 1] == colors[i] && colors[i] == colors[i + 1]) {\n            if (colors[i] == \'A\') {\n                count_A++;\n            } else {\n                count_B++;\n            }\n        }\n    }\n    return count_A > count_B;\n}\n\n```\n\n# \uD83C\uDFC6Note: \nI will soon add more three methods to solve this code in Python, Java, C++, C.\n\n# \uD83D\uDCA1 I invite you to check out my profile for detailed explanations and code for each method. Happy coding and learning! \uD83D\uDCDA
['Array', 'Linked List', 'Math', 'Two Pointers', 'String', 'Stack', 'C', 'C++', 'Java', 'Python3']