MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

RotateMatrix90Degree.java:1–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution
2{
3 //Function to rotate matrix anticlockwise by 90 degrees.
4 static void rotateby90(int matrix[][], int n)
5 {
6 // code here
7
8 for(int i=0;i<n/2;i++)
9 {
10 for(int j=i;j<n-i-1;j++)
11 {
12 // Store the first element
13 int temp = matrix[i][j];
14
15 matrix[i][j] = matrix[j][n-1-i];
16
17 matrix[j][n-1-i] = matrix[n-1-i][n-1-j];
18
19 matrix[n-1-i][n-1-j] = matrix[n-1-j][i];
20
21 matrix[n-1-j][i] = temp;
22 }
23 }
24
25 }
26}
27
28
29

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected