Skip to content

Commit

Permalink
Time: 0 ms (100%), Space: 42.2 MB (43.31%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit-S-Sahu committed Oct 23, 2024
1 parent 4a2bd81 commit 7c44974
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions 0048-rotate-image/0048-rotate-image.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution {
public void rotate(int[][] matrix) {
for(int i = 0; i< matrix.length; i++){
for(int j = i + 1; j < matrix.length; j++){
int temp = matrix[i][j];
matrix[i][j] = matrix[j][i];
matrix[j][i] = temp;
}
}
for(int i = 0; i < matrix.length; i++){
int start = 0;
int end = matrix.length - 1;

while(start < end){
int temp = matrix[i][start];
matrix[i][start] = matrix[i][end];
matrix[i][end] = temp;
end--;
start++;
}
}
}
}

0 comments on commit 7c44974

Please sign in to comment.