-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path048-RotateImage.cs
29 lines (27 loc) · 908 Bytes
/
048-RotateImage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//-----------------------------------------------------------------------------
// Runtime: 148ms
// Memory Usage:
// Link:
//-----------------------------------------------------------------------------
namespace LeetCode
{
public class _048_RotateImage
{
public void Rotate(int[,] matrix)
{
int i, j, temp;
var lenght = matrix.GetLength(1);
for (i = 0; i < lenght / 2; i++)
{
for (j = i; j < lenght - i - 1; j++)
{
temp = matrix[i, j];
matrix[i, j] = matrix[lenght - j - 1, i];
matrix[lenght - j - 1, i] = matrix[lenght - i - 1, lenght - j - 1];
matrix[lenght - i - 1, lenght - j - 1] = matrix[j, lenght - i - 1];
matrix[j, lenght - i - 1] = temp;
}
}
}
}
}