C++ || Faster than 100% || O(1) || Explained with approach
Please upvote if you like my solution.\n# Approach\n1. Number of \'O\' > Number of X -> return false\n    2. Number of X - Number of Os > 1 -> Return false\n   
**Please upvote if you like my solution.**\n# Approach\n1. Number of \'O\' > Number of X -> return false\n    2. Number of X - Number of Os > 1 -> Return false\n    3. If O wins -\n        a) Number of Os  == Number of Xs\n        b) And X should not be winning\n    4. If X wins -\n        a) O should not win\n         b) no. of x should be 1 more than no. of O\n# Complexity\n- Time complexity:\nO(1)\n\n\n# Code\n```\nclass Solution {\npublic:\n// 1. Number of \'O\' > Number of X -> return false\n//     2. Number of X - Number of Os > 1 -> Return false\n//     3. If O wins -\n//         a) Number of Os  == Number of Xs\n//         b) And X should not be winning\n//     4. If X wins -\n//         a) O should not win\n//         b) no. of x should be 1 more than no. of O\n    bool validTicTacToe(vector<string>& board) {\n        int o=0,x=0;\n        for(int i=0;i<3;i++)\n        {\n            for(auto j:board[i])\n            {\n                if(j == \'X\')\n                x++;\n                else if(j == \'O\')\n                o++;\n            }\n        }\n        if(o>x || (x-o > 1))return false;\n        bool winx = false,wino = false;\n        if(board[0] == "XXX" || board[1] == "XXX" || board[2] == "XXX")\n        winx=true;\n        if(board[0] == "OOO" || board[1] == "OOO" || board[2] == "OOO")\n        wino=true;\n\n        if(!winx || !wino)\n        {\n            string s1,s2,s3,s4,s5;\n            s1.push_back(board[0][0]);\n            s1.push_back(board[1][0]);\n            s1.push_back(board[2][0]);\n            s2.push_back(board[0][1]);\n            s2.push_back(board[1][1]);\n            s2.push_back(board[2][1]);\n            s3.push_back(board[0][2]);\n            s3.push_back(board[1][2]);\n            s3.push_back(board[2][2]);\n            s4.push_back(board[0][0]);\n            s4.push_back(board[1][1]);\n            s4.push_back(board[2][2]);\n            s5.push_back(board[0][2]);\n            s5.push_back(board[1][1]);\n            s5.push_back(board[2][0]);\n            if(s1 == "XXX" || s2 == "XXX" || s3== "XXX" || s4 == "XXX" || s5=="XXX")\n            winx=true;\n            \n            if(s1 == "OOO" || s2 == "OOO" || s3== "OOO" || s4 == "OOO" || s5=="OOO")\n            wino=true;\n\n        }\n        if(wino && winx)\n        return false;\n        if(wino)\n        {\n            if(o==x)\n            return true;\n            return false;\n        }\n        if(winx)\n        {\n            if(o+1 == x)\n            return true;\n            return false;\n        }\n        return true;\n    }\n};\n```
['Array', 'String', 'C++']