Reachable K-in-a-Row Board Position

Asked at Snowflake · Coding Questions · Difficulty: Medium · Last asked Nov 23, 2025

Two players take turns placing marks on an `N x N` grid: `X` always moves first, then `O`, alternating, one mark per turn on an empty cell. A player wins as soon as they own `K` consecutive cells in a straight line, and the game stops at that moment, so nobody moves after a win. Given a position, decide whether it could have occurred in such a game.

Loading the problem…