Mark As Completed Discussion

Good morning! Here's our prompt for today.

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!

Description

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)

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Here's how we would solve this problem...

How do I use this guide?