-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday14_2.java
More file actions
36 lines (32 loc) · 796 Bytes
/
day14_2.java
File metadata and controls
36 lines (32 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Solution
{
//Function to rotate matrix anticlockwise by 90 degrees.
static void rotateby90(int m[][], int n)
{
// code here
for(int i=0; i<n; i++)
{
for(int j = i; j<n ; j++)
{
int temp = m[i][j];
m[i][j] = m[j][i];
m[j][i] = temp;
}
}
int i =0;
boolean[] idx = new boolean[n];
while(i<n)
{
if(idx[i]==false){
for(int j=0; j<n; j++)
{
int temp = m[i][j];
m[i][j] = m[n-1-i][j];
m[n-1-i][j] = temp;
idx[n-1-i] = true;
}
}
i++;
}
}
}