1895. Largest Magic Square
Previous1894. Find the Student that Will Replace the ChalkNext1896. Minimum Cost to Change the Final Value of Expression
Last updated
Last updated
https://leetcode.com/problems/largest-magic-square
A k x k
magic square is a k x k
grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to be distinct. Every 1 x 1
grid is trivially a magic square.
Given an m x n
integer grid
, return the size (i.e., the side length k
) of the largest magic square that can be found within this grid.
Example 1:
Example 2:
Constraints:
m == grid.length
n == grid[i].length
1 <= m, n <= 50
1 <= grid[i][j] <= 106