#K77497. Rotate Matrix

    ID: 34877 Type: Default 1000ms 256MiB

Rotate Matrix

Rotate Matrix

Given a square matrix (A) of dimensions (n \times n), your task is to rotate the matrix 90° clockwise in-place. This operation means that the first row becomes the last column, the second row becomes the second-to-last column, and so on. The in-place operation should only use constant extra space aside from temporary variables. The problem tests your understanding of matrix manipulation and in-place algorithm design.

inputFormat

The input is provided via standard input. The first line contains an integer (n) representing the size of the matrix. This is followed by (n) lines, each containing (n) space-separated integers representing the rows of the matrix.

outputFormat

Print the rotated matrix to standard output. Each row of the output should be on a separate line with the integers separated by a single space.## sample

1
42
42

</p>