Rotate a Square Grid
Talk it through out loud with your AI coach.
The problem
- medium
- Pro
You're given a square grid of numbers, n rows by n columns, such as an image. Rotate it ninety degrees clockwise in place, without making a second grid. Explain your approach and how you'd rotate anticlockwise instead.
What a strong answer covers
- Breaking the rotation into two simpler in-place steps.
- Checking the order of those steps on a tiny grid.
- How the steps change for the other direction, or another method.
- Time and extra space.
Common mistake: Swapping across the diagonal for every cell rather than half of them, which swaps each pair twice and leaves the grid unchanged.
Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.
Practise it out loud