Tic Tac Toe Winner
Interview Question
Implement an algorithm that determines if someone has won a game of tic-tac-toe
Algorithm
- To determine if any of the two players have won the TicTacToe game or not, We need to know the following
-
Does any row, column or diagonal has scored the maximum?
-
Hence, we can aggregate the score for each row, column, diagonal in one dimension array.
For example, 3 * 3 board stateOfTheGame = [ row1, row2, row3, col1, col2, col3, diagonal1, diagonal2 ]