FastPrepTic-Tac-Toe Move Winners
Problems/Tic-Tac-Toe Move Winners

Tic-Tac-Toe Move Winners

ByteDance logoByteDance● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names the well-known tic-tac-toe exercise where moves come one at a time, but it does not give the full statement. Our version finds the winner after each move. It uses a finite list of legal moves, players who take turns, and limits on the board and on a batch of 500 moves. Those are our choices. Our version is about 85% the same as the reported question.

Implement an n × n tic-tac-toe game. Each move contains [row, column, player], where player is 1 or 2. After each move, return that player if the move completes a full row, column, top-left-to-bottom-right diagonal, or top-right-to-bottom-left diagonal; otherwise return 0.

For this exercise, represent the class calls as one finite ordered move sequence and return one result per move. Moves alternate players starting with player 1, use distinct cells and stop as soon as a player wins. Empty sequences return an empty list. Coordinates are zero-indexed.

Function

ticTacToeWinners(n: int, moves: int[][]) → int[]

Examples

Example 1

n = 3moves = [[0,0,1],[1,0,2],[0,1,1],[1,1,2],[0,2,1]]return = [0,0,0,0,1]

The final move completes the first row for player 1.

Example 2

n = 1moves = [[0,0,1]]return = [1]

The only cell completes a line.

Example 3

n = 3moves = []return = []

No calls means no outputs.

Constraints

  • 1 <= n <= 100.
  • 0 <= moves.length <= min(n^2, 500).
  • Each move is a triple with valid coordinates and player 1 or 2.
  • All moves are legal; no move follows a winning move.

More ByteDance Onsite Interview questions

  • Search a Row- and Column-Sorted MatrixONSITE INTERVIEW · Seen Nov 2026
  • Alien DictionaryPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lexicographically Smallest Topological OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Implement Multi-Head AttentionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dynamic Median with Additions and DeletionsONSITE INTERVIEW · Seen Oct 2026
  • Serialize and Deserialize a String Key-Value StoreONSITE INTERVIEW · Seen Oct 2026
  • Binary Tree Maximum Path SumONSITE INTERVIEW · Seen Oct 2026
  • Merge Overlapping IntervalsONSITE INTERVIEW · Seen Oct 2026
  • Kth Largest Element without a HeapONSITE INTERVIEW · Seen Oct 2026
  • Least Recently Used CachePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Cats, Rabbits, and Snails Board GameAsana · ONSITE INTERVIEW
  • Configurable Tic-Tac-Toe GameEliseAI · PHONE SCREEN
  • Ultimate Tic-Tac-Toe Move SimulatorHebbia · PHONE SCREEN
  • Priority Message BufferAmazon · ONSITE INTERVIEW
  • Spiral MatrixAthenahealth · ONSITE INTERVIEW
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions
  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions

ByteDance interview experiences

  • ByteDance TikTok USDS SWE Intern Interview: 1 Experience
  • ByteDance MLE New Grad Interviews: 1 Experience
  • ByteDance Security SRE Intern Phone Screens: 1 Experience
  • ByteDance USDS New Grad SWE Phone Screen: 1 Experience
  • ByteDance New Grad Data Engineer Video Interviews: 1 Experience
  • ByteDance Trust & Safety Research Scientist Intern: 1 Experience
All ByteDance interview questionsSee ByteDance hiring insights
Saved
class Solution {
    public int[] ticTacToeWinners(int n, int[][] moves) {
        // Write your code here.
    }
}
Checking account…