From ae506e52631f410eeeb1a80b8c3a51e37827e65a Mon Sep 17 00:00:00 2001 From: "Md.Sadiq" Date: Mon, 15 May 2023 21:27:09 +0530 Subject: [PATCH] Refactor -- Consiced to an Simpler Logic --- company/amazon/RotateImage.java | 44 +++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/company/amazon/RotateImage.java b/company/amazon/RotateImage.java index 17bd128c..8afc57d1 100644 --- a/company/amazon/RotateImage.java +++ b/company/amazon/RotateImage.java @@ -3,24 +3,42 @@ // Rotate the image by 90 degrees (clockwise). // Follow up: - // Could you do this in-place? + // Transpose and Swap the rows and Coloumns public class RotateImage { - public void rotate(int[][] matrix) { - for(int i = 0; i < matrix.length; i++) { - for(int j = 0; j < i; j++) { - int temp = matrix[i][j]; - matrix[i][j] = matrix[j][i]; - matrix[j][i] = temp; + public static void RotatedMatrix(int[][] arr) { + //1.Transpose the Matrix + for(int i=0;i