Given a 2D matrix, write a function that returns all elements of the matrix in spiral order.
For example, given the following matrix:
[
[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12],
[13, 14, 15, 16]
]
Your function should return:
[1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10]
Instructions:
Note: This problem can be a fun challenge to celebrate the creativity and problem solving skills that professionals bring to every day of the year. Happy coding on this November day!