LC: Design Tic Tac Toe - spiralgo/algorithms GitHub Wiki
The Essence:
Instead of trying to check each time if a win condition is satisfied, one can store the amount of moves made by each player on the diagonal, anti-diagonal, each column and each row. When a new input from some player is given, the program should be able to check if any of these locations are filled.
The aspect to notice here is that using stored data can actually be more efficient than not storing but computing each time.
Details:
The aforementioned filling checks can be implemented using arrays. Simply, the count for a single player one each of these is checked to output victory or not.