LeetCode – Rotate Image (Java)
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? In-place Solution By using the relation “matrix[i][j] = matrix[n-1-j][i]”, we can loop through the matrix. public void rotate(int[][] matrix) { int n = matrix.length; for (int i = 0; … Read more