Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (18 sloc) 381 Bytes

59. Spiral Matrix II

Description

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

Example

Example:

Input: 3
Output:
[
 [ 1, 2, 3 ],
 [ 8, 9, 4 ],
 [ 7, 6, 5 ]
]

Translation

54、Spiral Matrix 类似。一个是读,这个是写

Ideas

Note

You can’t perform that action at this time.