Skip to content

Commit

Permalink
Java solution for rotata image Problem of leetcode
Browse files Browse the repository at this point in the history
Rotatae image solution of java (in place algorithm)
  • Loading branch information
yuvrajverma25 authored Oct 18, 2023
1 parent 4efd7a0 commit 7340902
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Rotate Image
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
public void rotate(int[][] matrix) {
int n = matrix.length;
for (int i = 0; i < (n + 1) / 2; i ++) {
for (int j = 0; j < n / 2; j++) {
int temp = matrix[n - 1 - j][i];
matrix[n - 1 - j][i] = matrix[n - 1 - i][n - j - 1];
matrix[n - 1 - i][n - j - 1] = matrix[j][n - 1 -i];
matrix[j][n - 1 - i] = matrix[i][j];
matrix[i][j] = temp;
}
}
}
}

0 comments on commit 7340902

Please sign in to comment.