59. Spiral Matrix II
From LeetCode. LeetCode Problem. Solve the geometry problem "59. Spiral Matrix II".
Examples
Input: [1,2,3]
Output: 0
Input: [2,3,4]
Output: 0
Hints
Track 4 boundaries: top, bottom, left, right. Shrink each boundary after completing a side. Direction cycle: right → down → left → up, repeat until all n² numbers placed.
Fill top row left→right then top++, right col top→bottom then right--, bottom row right→left then bottom--, left col bottom→top then left++. Stop when a boundary crosses its opposite.
n=1 returns [[1]]. For odd n, center cell fills last when top==bottom && left==right after all layers done. Use n=0 guard? n ≥ 1 in problem spec.
59. Spiral Matrix II
**From LeetCode.** LeetCode Problem. Solve the geometry problem "59. Spiral Matrix II".