Fill Matrix

Problem Overview

  • Fill an N×N matrix with integers 1 to N^2 so each row, column, and both main diagonals have the same sum.
  • Input: integer N; Output: an N×N matrix satisfying the equal-sum property; constraints are unspecified.
  • Domain: matrix construction and combinatorics, similar to puzzle-style grid arrangement.
  • From Google interviews; a classic coding interview problem and common interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: