Community

Start a Thread


Notifications
Subscribe You’re not receiving notifications from this thread.

Traverse a Matrix in Spiral Order (Main Thread)

Here is the interview question prompt, presented for reference.

Given an m * n matrix array, can you print all its elements in a spiral order as shown in the figure below? Try to use only O(1) space!

Constraints

  • Total elements in the matrix <= 100000
  • The values in the matrix ranges from -1000000000 and 1000000000
  • Expected time complexity : O(n*m) where n and m are the rows and columns respectively
  • Expected space complexity : O(1)

You can see the full challenge with visuals at this link.

Challenges • Asked about 5 years ago by Jake from AlgoDaily

Jake from AlgoDaily Commented on Apr 05, 2019:

This is the main discussion thread generated for Traverse a Matrix in Spiral Order.