Trace the boundary of a matrix in clockwise order!
Traverse from (0, 0) to (0, cols-1)
for c = 0 to cols-1
Traverse from (1, cols-1) to
(rows-1, cols-1)
for r = 1 to rows-1
Traverse from (rows-1, cols-2) to
(rows-1, 0)
for c = cols-2 to 0
Traverse from (rows-2, 0) to (1, 0)
for r = rows-2 to 1