board of positive integers.
Consider paths through side-adjacent cells that first go straight, horizontally or vertically, and then may turn by 90° once and go straight again. No cell is visited twice. A path may also have no turn at all, or even consist of a single cell.
Multiply the numbers in all cells of the path. Return the largest number of trailing zeros such a product can have.board=[[4, 7, 25], [3, 5, 2], [8, 1, 6]] → 2
The path 4 → 7 → 25, then down through 2 → 6, has product 4·7·25·2·6 = 8400, which ends in two zeros. No path does better.
board=[[3, 7], [9, 11]] → 0
No cell has a factor of 2 or 5, so no product ends in a zero.
board=[[10, 2, 5, 50]] → 3
board=[[4, 7, 25], [3, 5, 2], [8, 1, 6]]
2
Run checks the first 3 tests in your browser. Submit checks all 79 tests on the server, hidden ones included.