From db245988bb097ed10ea6c3cb8b9aca6477377566 Mon Sep 17 00:00:00 2001 From: Amit S Sahu Date: Wed, 23 Oct 2024 13:58:52 +0530 Subject: [PATCH] Time: 0 ms (100%), Space: 41.9 MB (88.03%) - LeetHub --- .../0048-rotate-image-brute_force.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 0048-rotate-image/0048-rotate-image-brute_force.java diff --git a/0048-rotate-image/0048-rotate-image-brute_force.java b/0048-rotate-image/0048-rotate-image-brute_force.java new file mode 100644 index 0000000..469b8b7 --- /dev/null +++ b/0048-rotate-image/0048-rotate-image-brute_force.java @@ -0,0 +1,19 @@ +class Solution { + public void rotate(int[][] matrix) { + int n = matrix.length; + int res[][] = new int[n][n]; + + for(int i = 0; i < n; i++){ + for(int j = 0; j < n; j++){ + res[j][n - 1 - i] = matrix[i][j]; + } + } + + for(int i= 0; i < n; i++){ + for(int j = 0; j < n; j++){ + matrix[i][j] = res[i][j]; + } + } + + } +} \ No newline at end of file