← Interval & Math

Micro-Drill #116 — Rotate matrix 90° CW

Interval & Math Target: 15s

Transpose + reverse-rows rotates 90 degrees clockwise in-place. Classic matrix manipulation.

n = len(m)
for i in range(n):
    for j in range(i+1, n):
        m[i][j], m[j][i] = m[j][i], m[i][j]
for row in m:
    row.reverse()

Type it from memory. Go.

Practice Problems

Related Coding Drills

← Micro #115 Micro #117 →