Amazon Interview Question

Write a program to traverse the matrix like a spiral.