Spiral Order

Medium · rating 1500 · Matrix, Implementation

The first line contains r and c. The next r lines each have c integers. Print all elements in clockwise spiral order starting from the top-left, space-separated on one line.

Constraints: 1 ≤ r, c ≤ 100

Related problems

Open Spiral Order in Code Arena →