Sunday 16 October 2022

Array - 48. Rotate Image

#===================================
# Tanzila Islam
# Email: tanzilamohita@gmail.com
# Language: Python 3
#===================================
class Solution:
    def rotate(self, matrix: List[List[int]]) -> None:
        """
        Do not return anything, modify matrix in-place instead.
        """
        n = len(matrix)
        for row in range(n):
            for col in range(row+1, n):
                matrix[row][col], matrix[col][row] = matrix[col][row], matrix[row][col]
        
        for row in range(n):
            matrix[row].reverse()
            

        

No comments:

Post a Comment