#34 - Find Winner on a Tic Tac Toe Game
You are given a 3x3 Tic-Tac-Toe board as a list of lists, where each inner list represents a row in the board. Each cell in the board contains either "X", "O", or an empty space " ".
Your task is to implement a function to determine the winner of the game.
The winner can be "X" if player X has filled either a row, a column, or a diagonal with their symbol.
Similarly, the winner can be "O" if player O has filled either a row, a column, or a diagonal with their symbol.
If there is no winner yet but board is incomplete, the game is considered to be ongoing.
If there is no winner yet but board is complete, match is found to be Draw.
Example 1
Input
Output
Example 2
Input
Output
Example 3
Input
Output
Example 4
Input
Output
Last updated