Rotate a matrix 90 degrees Transpose a matrix and reverse each row to rotate it clockwise. 18th August 2026 def transpose_and_reverse(matrix): return [list(reversed(row)) for row in zip(*matrix)]