Created
May 8, 2022 02:07
-
-
Save svaza/15edc3aa1edcfc8c4af327b7468687e8 to your computer and use it in GitHub Desktop.
Rotate Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Solution { | |
public void Rotate(int[][] matrix) { | |
for(int i = 0; i < matrix.Length/2; i++) | |
{ | |
for(int j = i; j < matrix[i].Length - 1 - i; j++) | |
{ | |
int b = matrix[j][matrix[i].Length-1-i]; | |
matrix[j][matrix[i].Length-1-i] = matrix[i][j]; | |
int b2 = matrix[matrix.Length-1-i][matrix[i].Length-1-j]; | |
matrix[matrix.Length-1-i][matrix[i].Length-1-j] = b; | |
int b3 = matrix[matrix.Length-1-j][i]; | |
matrix[matrix.Length-1-j][i] = b2; | |
matrix[i][j] = b3; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment