Thursday, November 27, 2014

Spiral Matrix II

Problem

Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.

For example,
Given n = 3,

You should return the following matrix:

Idea


Solution


No comments:

Post a Comment