Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.

Example 1: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,3,6,9,8,7,4,5] The Solution is very simple. As shown in the image above, 1. We traverse right 2. We traverse down 3. We traverse left 4. We traverse up To achieve this, we take 4 … Continue reading Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.