m x n matrix with all elements set to -1.top, bottom, left, and right to represent the current limits for traversal.left to right boundary and fill the topmost row, then increment top boundary.top to bottom boundary and fill the rightmost column, then decrement right boundary.right to left boundary and fill the bottommost row, then decrement bottom boundary.bottom to top boundary and fill the leftmost column, then increment left boundary.