implement rotate_image given imputs size, img to rotate square arrays representing…
- User
implement rotate_image given imputs size, img to rotate square arrays representing images. rotate counter clockwise 90 degrees.
- Assistant
To rotate a square image (represented as a 2D array) counter-clockwise by 90 degrees, you can perform the following steps:
- Reverse each row: This transforms the image horizontally.
- Transpose the matrix: Swap elements across the diagonal to rotate the image.
Here's how you can implement this in Python:
python