Day 19 Task:
7. Rotate Image: https://leetcode.com/problems/rotate-image/
Solution Approach: https://leetcode.com/problems/rotate-image/solution/
Solutions:
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
def transpose(matrix):
for i in range(len(matrix)):
for j in range(i, len(matrix)):
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
def element_exchange(matrix):
for i in range(len(matrix)):
matrix[i] = matrix[i][::-1]
matrix = matrix[::-1]
transpose(matrix)
element_exchange(matrix)