Very Easy Java Solution With Detailed Explation| Beats 70%
Idea behind it is that you need to count the number of triplets of both A and B \nint a -> number of triplets of \'A\'\nint b -> number of triplets of \'B\'\nif
Idea behind it is that you need to count the number of triplets of both A and B \nint a -> number of triplets of \'A\'\nint b -> number of triplets of \'B\'\nif(b>=a) BOB wins else Alice wins\n\nAs Alice has to make a move first so if she wants to win there should be atleast  1 more  triplets of A than B\n\nEg There are 4 triplets of both A and B  (a=4, b=4) \n1. Alice removes 1 A (a=3, b=4)\n2. Bob removes 1 B (a=3, b=3)\n3. (a=2, b=3)\n4. (a=2, b=2)\n5. (a=1, b=2)\n6. (a=1, b=1)\n7. (a=0, b=1)\n\nClearly Alice will lose if both have same number of triplets\nCode \n\n```\nclass Solution {\n    public boolean winnerOfGame(String s) {\n        //count the triplets\nint n = s.length();\n    \n        int a=0;\n        int b=0;\n        \n        for(int i=1; i<n-1; i++)\n        {\n            if(s.charAt(i)==\'A\' && s.charAt(i-1)==\'A\' && s.charAt(i+1)==\'A\' )\n        a++;\n            else if(s.charAt(i)==\'B\' && s.charAt(i-1)==\'B\' && s.charAt(i+1)==\'B\' )\n        b++;\n            \n            }\n        if(a<=b)\n            return false;\n        else\n            return true;\n        \n    \n    }\n}\n```\nIf this helped you then please UpVote\nThanks\n\n\n
['Java']