Description
Solutions
Submission
Fill Matrix

Given a NxN matrix. Fill the integers from 1 to n*n to this matrix that makes the sum of each row, each column and the two diagonals equal.

Example 1:

Input:  n = 2
Output: null
Explanation:
We need to fill [1, 2, 3, 4] into a 2x2 matrix, which is not possible so return null.

Example 2:

Input:  n = 3
Output: [[8, 3, 4], [1, 5, 9], [6, 7, 2]]
Explanation:
We need to fill [1, 2, 3... 9] into a 3x3 matrix. This is one way to do it. Each row [8, 3, 4], [1, 5, 9], [6, 7, 2] sum is 15. Each column [8, 1, 6], [3, 5, 7], [4, 9, 2] sum is 15. The two diagonals [8, 5, 2] and [4, 5, 6] sum is 15.
Constraints:
    Unknown yet. If you happen to know about it, feel free to lmk! TYSM ~3~
Thumbnail 0
Testcase

Result
Case 1

input:

output: