m × n integer table grid. A diagonal is the set of cells you visit by starting at any cell and stepping down and to the right until you leave the table.
Return true if every such diagonal contains a single repeated value, and false otherwise.grid=[[7, 0, 3], [8, 7, 0], [5, 8, 7], [6, 5, 8]] → True
Every down-right diagonal holds one value: [6], [5, 5], [8, 8, 8], [7, 7, 7], [0, 0], [3].
grid=[[4, 1], [2, 5]] → False
The main diagonal holds 4 and 5, which differ.
grid=[[9, 9, 9, 9]] → True
With a single row, every diagonal is one cell long, so the condition holds.
m, n ≤ 20grid[i][j] ≤ 99grid=[[7, 0, 3], [8, 7, 0], [5, 8, 7], [6, 5, 8]]
True
Run checks the first 3 tests in your browser. Submit checks all 87 tests on the server, hidden ones included.