New update is available. Click here to update.

# Tic-Tac-Toe Winner

Contributed by
Vishal Modani
Last Updated: 23 Feb, 2023
Easy
0/40
Avg time to solve 20 mins
Success Rate 80 %
Share
11 upvotes

## Problem Statement

#### Example :

``````n = 5, moves = {{0,2}, {0,0}, {1,1}, {2,2}, {2,0}}
``````

#### Note :

``````1. The array ‘moves’ doesn’t contain any repeating positions, and all positions are valid.
2. The array ‘moves’ follows all the rules of tic-tac-toe.
3. You do not need to print anything; it has already been taken care of. Just implement the function
``````
Detailed explanation ( Input/output format, Notes, Images )

#### Sample input 1 :

``````2
9
0 0
0 1
1 1
1 0
2 1
2 2
2 0
0 2
1 2
5
0 0
1 1
0 2
2 2
2 1
``````

#### Sample output 1 :

``````draw
uncertain
``````
##### Explanation of sample input 1 :
``````Test Case 1:
``````

``````There is no row, column, or diagonal with three same characters after performing the given nine moves. Hence there is no winner. With no more moves to make (all grid positions are marked), the game ends in a draw. So, the answer is ‘draw’.

Test Case 2:
``````

``````There is no row, column, or diagonal with three same characters after performing the given five moves. Hence there is no winner as of now. With four grid positions remaining unmarked, the winner of the game is uncertain. So, the answer is ‘uncertain’.
``````

#### Sample input 2 :

``````2
6
0 0
1 1
2 2
0 2
1 0
2 0
5
0 1
1 2
2 1
1 0
1 1
``````

#### Sample output 2 :

``````player2
player1
``````
Auto
Console