Leetcode 48: Rotate Image

The idea with my solution is that you work your way through layers of the box, starting with the outside layer and then moving inwards. For each layer we step through four points at a time, starting at the corners and then working our way around to other points on the edges. On the whiteboard I have highlighted the order with colours. I find it easiest to figure out the outermost layer first and then modify the logic to handle layer offsets.

This entry was posted in programming and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.