Generate an M × N Spiral Matrix
Given two positive integers m and n, generate an m × n matrix.
Starting at the top-left cell (0, 0), fill the integers from 1 to m × n in clockwise spiral order: move right first, the...
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
