field of positive integers. A k × k square block (a contiguous piece of the table) is **balanced** if all k of its rows, all k of its columns and both of its diagonals have the same sum. Values inside may repeat. Every single cell is a balanced 1 × 1 square.
Return the side length of the largest balanced square in the table.field=[[2, 7, 6, 5], [9, 5, 1, 3], [4, 3, 8, 2]] → 3
The left 3×3 square is balanced: every row, column and both diagonals add up to 15.
field=[[4, 4, 1], [4, 4, 2]] → 2
The 2×2 square of fours has every line summing to 8. A 3×3 square does not fit in a 2×3 table.
field=[[1, 2], [3, 4]] → 1
The 2×2 square is not balanced, so only 1×1 cells remain and the answer is 1.
field=[[2, 7, 6, 5], [9, 5, 1, 3], [4, 3, 8, 2]]
3
Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.