|| 0ms || Simple C++ Solution || With Explanation ||
```\nclass Solution {\npublic:\n    bool winn(vector brd,char c)  // Checking all vertical lines,horizontal lines and the two dialgonals to conclude a win\n    
```\nclass Solution {\npublic:\n    bool winn(vector<string> brd,char c)  // Checking all vertical lines,horizontal lines and the two dialgonals to conclude a win\n    {\n        if((brd[0][0 ]== c && brd[1][0] == c&& brd[2][0] == c)||(brd[0][1] == c && brd[1][1]==c && brd[2][1] == c)\n           ||(brd[0][2] == c && brd[1][2] == c && brd[2][2] == c)||(brd[0][0] == c && brd[0][1] == c && brd[0][2] == c)\n           ||(brd[1][0] == c && brd[1][1] == c && brd[1][2] == c)||(brd[2][0] == c && brd[2][1] == c && brd[2][2] == c)\n           ||(brd[0][0] == c && brd[1][1] == c && brd[2][2] == c)||(brd[0][2] == c && brd[1][1] == c && brd[2][0] == c)) \n        {\n          return(true);\n        }\n        return(false);\n    }\n    bool validTicTacToe(vector<string>& board) \n    {\n        int x = 0,o = 0;          //x tracks count of \'X\'       and          o tracks the occurance of \'O\'\n        for(string s : board)\n        {\n            for(char c : s)\n            {\n                if( c == \'X\')\n                {\n                    x++;\n                }\n                else if(c == \'O\')\n                {\n                    o++;\n                }\n            }\n        }\n        if(x == o || x == o+1)      // the frequency of X in a valid game is either equal to the (frequency of O) or equal to (frequency of O +1)\n        {\n            bool win_x = winn(board,\'X\'),win_o = winn(board,\'O\');\n            if(win_x)        // If X wins then surely O shouldn\'t win in a valid game\n            {\n                if(win_o)       //If O wins then surely board is invalid\n                {\n                    return false;\n                }\n                return (x == o + 1);         //If X wins then surely the frequency of X is = Frequency of O  (AS X played first)\n            }\n            if(win_o)           //If O wins then surely the frequency of O is = Frequency of X  (AS O played second, it can\'t play more moves than X)\n            {\n                return (x == o);\n            }\n            return true;     //If nobdy wins then its a valid board, as the frequency condition is satisfied\n        }\n        return false;    \n    }\n};
['C++']