Skip to content

Commit 803060f

Browse files
authored
Added Solution for LeetCode Problem No. 48
1 parent 676266a commit 803060f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// https://leetcode.com/problems/rotate-image/
2+
3+
class Solution {
4+
public void rotate(int[][] matrix)
5+
{
6+
for(int i = 0; i<matrix.length; i++)
7+
{
8+
for(int j = i; j<matrix[0].length; j++)
9+
{
10+
int temp = 0;
11+
temp = matrix[i][j];
12+
matrix[i][j] = matrix[j][i];
13+
matrix[j][i] = temp;
14+
}
15+
}
16+
17+
for(int i =0 ; i<matrix.length; i++)
18+
{
19+
for(int j = 0; j<matrix.length/2; j++)
20+
{
21+
int temp = 0;
22+
temp = matrix[i][j];
23+
matrix[i][j] = matrix[i][matrix.length-1-j];
24+
matrix[i][matrix.length-1-j] = temp;
25+
}
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)