Rotate Image

Given an n × n matrix, rotate it 90 degrees clockwise. The platform calls solve(matrix) as a functional entry point and uses its returned matrix as the result. Your implementation must also modify the provided matrix so that the returned value is the updated input matrix. Returning an unrelated newly allocated matrix without updating the provided matrix is not sufficient. The brute-force baseline may use an auxiliary matrix, then must copy the rotated values back into the provided matrix; the optimal approaches use O(1) auxiliary space.

Examples
Input: [[1,2,3],[4,5,6],[7,8,9]]
Output: [[7,4,1],[8,5,2],[9,6,3]]
Hints
Related Problems

Rotate Image

Given an `n × n` matrix, rotate it 90 degrees clockwise. The platform calls `solve(matrix)` as a functional entry point and uses its returned matrix as the result. Your implementation must also modify the provided matrix so that the returned value is the updated input matrix. Returning an unrelated newly allocated matrix without updating the provided matrix is not sufficient. The brute-force baseline may use an auxiliary matrix, then must copy the rotated values back into the provided matrix; the optimal approaches use O(1) auxiliary space.