Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 426 Bytes

0059-spiral-matrix-ii.adoc

File metadata and controls

26 lines (19 loc) · 426 Bytes

59. Spiral Matrix II

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

Example:

Input: 3
Output:
[
 [ 1, 2, 3 ],
 [ 8, 9, 4 ],
 [ 7, 6, 5 ]
]
link:{sourcedir}/_0059_SpiralMatrixII.java[role=include]