Construct a grid by placing values so that a special row-and-column condition is satisfied.
You are given an integer . Build an grid using the values from $0n^2 - 1$ exactly once each.
The grid must be filled so that the arrangement follows a special rule based on the recursive structure of the grid: values are assigned in groups to sub-squares, and each smaller square is filled consistently according to the same rule until the grid is complete.
Your task is to return any valid grid that satisfies the rule.
n describing the side length of the grid.n x n integer grid containing every value from 0 to n^2 - 1 exactly once.Example 1
Input
n = 2
Output
[[0,1],[2,3]]
Explanation
This is one valid 2x2 grid using each value exactly once.
Example 2
Input
n = 3
Output
[[0,1,2],[3,4,5],[6,7,8]]
Explanation
This is another valid grid example that uses every number from 0 to 8 exactly once.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.