tomtom's note: Feel free to check out the source image below for the original problem statement :)
Imagine you have a beautiful square matrix and a number, turns. Your mission is to gracefully rotate this matrix turns times "over its diagonals," creating a new, enchanting pattern with each rotation. After you've completed the rotations, you'll return the transformed matrix, now dressed in its new, elegant arrangement. 🌟
The elements along the two main diagonals remain beautifully in place, untouched by the rotation. However, the four sections formed by these diagonals gracefully swap positions in a clockwise dance. With each rotation, these segments move to their new spots, creating a fresh, charming pattern. Take a look at the images below to see this elegant transformation in action! 🌼
ദ്ദി(˵ •̀ ᴗ - ˵ ) ✧ Credit to robot ༊࿐ ͎. 。˚ ° ˚🧡.
Example 1:
Input: matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20],[21, 22, 23, 24, 25]], turns = 1
Output: [[1, 16, 11, 6, 5], [22, 7, 12, 9, 2], [23, 18, 13, 8, 3], [24, 17, 14, 19, 4], [21, 20, 15, 10, 25]]
Explanation:🐡
🐰


input:
output: