Problem 48 · Medium

Rotate Image

Rotate a square matrix ninety degrees clockwise without allocating a second matrix. The visual moves each value through its four-cell cycle, holding the displaced value until it has been placed.

Open the interactive visualisation