using KMP in c++
\nclass Solution {\n    \n\n    int findcount(vector<int>&points,string search,string pattern)\n{\n    int i=0;\n    int j=0;\n        int count=0;\n    while(i
```\nclass Solution {\n    \n\n    int findcount(vector<int>&points,string search,string pattern)\n{\n    int i=0;\n    int j=0;\n        int count=0;\n    while(i<search.size())\n    {\n        if(search[i]==pattern[j])\n        {\n            i++;\n            j++;\n        }\n        else\n        {\n           if(j!=0)\n           {\n               j=points[j-1];\n           }\n           else\n           {\n               i++;\n           }\n        }\n        if(j==points.size())\n        {\n            // cout<<i-points.size()<<endl;\n            // break;\n            count++;\n            j=points[j-1];\n        }\n\n    }\n    return count;\n}\npublic:\n    bool winnerOfGame(string colors) {\n        \n        vector<int>temp1={0,1,2};\n        string pattern="AAA";\n        string pattern2="BBB";\n        int countalice= findcount(temp1,colors,pattern);\n        int countbob= findcount(temp1,colors,pattern2);\n        \n        if(countalice>countbob)\n        {\n            return true;\n        }\n        else\n        {\n            return false;\n        }\n       \n    }\n};\n```
[]