Spiral Matrix II
Medium · Arrays & Strings · about 15 minutes
Asked at Amazon, Microsoft, Apple, Adobe, eBay, Autodesk.
Given a positive integer n, return an n × n matrix filled with 1, 2, …, n² in spiral order (clockwise, starting at the top-left).