O85

Design Tic-Tac-Toe

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: ARRAY

Problem Statement & Objective

Design a Tic-tac-toe game that is played between two players on an n x n grid with O(1) move evaluation.

Function Signature (Python)

design_tictactoe(n: int, moves: list) -> list[int]

Input & Output Contract

Output Rule:Her hamle için kazanan durumunu (0, 1 veya 2) içeren liste.

System Constraints

2 <= n <= 1000
1 <= hamleler.length <= n^2
0 <= satir, sutun < n

Example Execution Walkthrough

n = 3, hamleler = [[0, 0, 1], [0, 2, 2], [2, 2, 1], [1, 1, 2], [2, 0, 1], [1, 0, 2], [2, 1, 1]]
Son hamlede 1. oyuncu 2. satırı tamamlar -> 1
Cevap: [0, 0, 0, 0, 0, 0, 1]

Example Test Scenarios (3)

Example 1: Satır Zaferi
Input:[3,[[0,0,1],[0,2,2],[2,2,1],[1,1,2],[2,0,1],[1,0,2],[2,1,1]]]
Expected Output:[0,0,0,0,0,0,1]
Example 2: Çapraz Zafer (2x2)
Input:[2,[[0,0,1],[0,1,2],[1,1,1]]]
Expected Output:[0,0,1]
Example 3: Kazanan Yok
Input:[3,[[0,0,1],[1,1,2]]]
Expected Output:[0,0]
Loading Python Editor...
Input Parameters
[
  3,
  [
    [
      0,
      0,
      1
    ],
    [
      0,
      2,
      2
    ],
    [
      2,
      2,
      1
    ],
    [
      1,
      1,
      2
    ],
    [
      2,
      0,
      1
    ],
    [
      1,
      0,
      2
    ],
    [
      2,
      1,
      1
    ]
  ]
]
Expected Output
[
  0,
  0,
  0,
  0,
  0,
  0,
  1
]