Leetcode 59: Spiral Matrix II

Process using one layer at a time, starting from the outer layer. The fiddly bit is getting the matrix coordinates correct and I plan that up front taking out the complication of layers.

Here is the code for the above plan:
And here is a more concise version, where I don’t have a separate layer function:

This entry was posted in programming and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.