Rotate matrix counter-clockwise
Your task
Rotate an n x n matrix 90 degrees COUNTER-clockwise in place (no extra matrix allocation) and return it. The matrix is square with n up to 100. Note: counter-clockwise is the less common direction, so be careful with the reflection order.
Examples
rotate_ccw(matrix: list[list[int]]) -> list[list[int]]Example 1
Input
rotate_ccw([[1, 2, 3], [4, 5, 6], [7, 8, 9]])Output
[[3, 6, 9], [2, 5, 8], [1, 4, 7]]