Leetcode 59 - Spiral matrix II

Note:

• Update:
• Just pray it won’t appear in my interview. Not hard, but a pain in the ass.
• How to initialize an empty 2D array?
const arr = [...Array(n)].map(e => Array(n))
• Keep [start, right) style - make the right boundary open so you won’t be lost.
• Speical case for the last node when n is odd.

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