size × size square. Every cell is clear except the mined ones: each pair [r, c] in mines puts a mine at row r, column c.
A **cross of order k** is a clear center cell plus four arms of clear cells, each of length k - 1, going up, down, left and right. A cross of order 1 is a single clear cell. Whatever lies beyond the ends of the arms does not matter.
Return the order of the largest cross that fits on the field, or 0 if there are no clear cells.size=5, mines=[[0, 0], [4, 1]] → 3
Centered at (2, 2), all four arms of length 2 are clear (the mines at (0, 0) and (4, 1) are off the arms). That is a cross of order 3, the most a 5×5 field allows.
size=2, mines=[[0, 0], [1, 1]] → 1
Only (0, 1) and (1, 0) are free, and each is next to an edge or a mine, so only a cross of order 1 fits.
size=1, mines=[[0, 0]] → 0
The only cell holds a mine, so there is no cross and the answer is 0.
mines are distinctsize=5, mines=[[0, 0], [4, 1]]
3
Run checks the first 3 tests in your browser. Submit checks all 91 tests on the server, hidden ones included.