Mental Model
We walk around the edges of the matrix in a circle, then move inward layer by layer until all elements are visited.
Analogy: Imagine peeling an onion layer by layer, starting from the outer skin and moving towards the center, collecting all the layers as you go.
1 -> 2 -> 3 -> 4 ā ā 5 6 ā ā 7 ā 8 ā 9 ā 10 We start at top-left, move right, then down, then left, then up, shrinking the boundaries each time.