[JAVA] 100% fast, with explanation in detail
\'\'\'\nclass Solution {\n    public boolean winnerOfGame(String colors) {\n        \n        if(colors.length() <=2)\n        {\n            return false;  // 
\'\'\'\nclass Solution {\n    public boolean winnerOfGame(String colors) {\n        \n        if(colors.length() <=2)\n        {\n            return false;  // BOB will win if "AA" or "BB" or "A" or "B"\n        }\n        \n        int[] triple = triplets(colors); //Calculating all the triplets in the string AAA, BBB\n\n        if(triple[0] > triple[1])\n        {\n            return true;    //Alice wins, as it has more number of triplets\n        }\n        else\n        {\n            return false; //Bob wins, also this condition will be true when triple A == triple B \n        }\n    }\n\n    \n    public int[] triplets(String colors)\n    {\n        int tripleA = 0, tripleB = 0;\n        \n        for(int i = 2; i<colors.length(); i++)    // i=2, so that it does not give array out of bounds exception\n        {\n            //If, we get 3 continous A\'s\n            if(colors.charAt(i-2) == \'A\' && colors.charAt(i-1) == \'A\' && colors.charAt(i) == \'A\')\n            {\n                tripleA++;    \n            }\n            //If, we get 3 continous B\'s\n            else if(colors.charAt(i-2) == \'B\' && colors.charAt(i-1) == \'B\' && colors.charAt(i) == \'B\')\n            {\n                tripleB++;\n            }\n        }\n        return new int[] {tripleA, tripleB};  \n    }\n}\n\'\'\'
['Java']