Skip to content

Instantly share code, notes, and snippets.

@svaza
Created May 8, 2022 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svaza/15edc3aa1edcfc8c4af327b7468687e8 to your computer and use it in GitHub Desktop.
Save svaza/15edc3aa1edcfc8c4af327b7468687e8 to your computer and use it in GitHub Desktop.
Rotate Image
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