Find Winner on a Tic Tac Toe Game
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Two players, A and B, play tic-tac-toe on a 3x3 grid. A always moves first and marks X; B marks O. Players alternate, so moves[0] is A's, moves[1] is B's, and so on. Each moves[i] = [row, col] names an empty cell.
The game stops as soon as someone fills a whole row, column, or diagonal with their mark, or when all nine cells are filled. The given moves always describe a legal game, and no moves appear after the game has ended.
Return "A" or "B" if that player won, "Draw" if the grid is full with no winner, and "Pending" if there is no winner and empty cells remain.
Examples
Constraints
- 1 <= moves.length <= 9
- moves[i].length == 2
- 0 <= row, col <= 2
- All moves are distinct and form a legal game that has not continued past its end.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.