Back to problems

Winner in a Dot Grid Game

Algorithm · Hudson River Trading · Medium

Two players take turns placing sticks on a 9×9 grid of dots. You are given a list moves, where each entry moves[i] = [r1, c1, r2, c2] represents a stick drawn between dot (r1, c1) and dot (r2, c2). A stick may only connect two dots that are adjacent — either horizontally or vertically next to each other. The players alternate turns: Player 1 makes the 1st, 3rd, 5th, … moves, and Player 2 makes the 2nd, 4th, 6th, … moves. The game stops the moment at least one 1×1 square is…

Checking your access…