The Spiral Matrix problem takes a 2-Dimensional array of N-rows and M-columns as an input, and prints the elements of this matrix in spiral order.
The spiral begins at the top left corner of the input matrix, and prints the elements it encounters, while looping towards the center of this matrix, in a clockwise manner.
This continues until the left index is greater than the right index, and the top index is greater than the bottom index.
The following code implements the spiral matrix algorithm in C++, Python, and Java: