Back to problems

Spiral Matrix Generation

Algorithm · Pinduoduo · Medium

Requirements Given dimensions m and n, build and return an m x n rectangular matrix whose values are placed in clockwise spiral order. Treat the main task as the matrix-generation variant in the LC 59 family, not as a traversal of a matrix supplied by the caller. For the follow-up, a cell containing -1 is unavailable and must cause a turn just as a boundary or previously unavailable cell would. Before implementation, clarify the initial value, the interval of values to…

Loading the rest of the question…