Clockwise Outside-In Walk of a Grid

Asked at Goldman Sachs · Coding Questions · Difficulty: Medium · Last asked Nov 15, 2024

Read every element of a rectangular grid in a clockwise walk that starts at the top-left corner and winds inward. Walk right along the top row, down the right column, left along the bottom row and up the left column, then repeat on the smaller rectangle inside, until every element has been visited exactly once.

Loading the problem…