Let's trace a 2 x 3 matrix [[1,2,3],[4,5,6]].
Start at (0,0), direction = up-right. Read .
Move up-right: (-1,1). Row out of bounds. Flip to down-left. Adjust: (0,1). Read .
Move down-left: (1,0). Valid. Read .
Move down-left: (2,-1). Both out of bounds. Flip to up-right. Col so adjust to (2,0), but row so adjust again to (1,1). Read . Flip direction.
This continues until all elements are visited.
You visit each cell once and do constant work per cell. time, space (not counting the output array).