Rotate Image java (2D Array Runtime 0ms ).

class Solution {
public void rotate(int[][] matrix) {
int l=matrix.length;
int arr[][]=new int[l][l];
for(int i=0;i<l;i++){
for(int j=0;j<l;j++){
arr[j][l-i-1]=matrix[i][j];
}
}
for(int i=0;i<l;i++){
for(int j=0;j<l;j++){
matrix[i][j]=arr[i][j];
}
}
}
}

Comments (1)