-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.cs
More file actions
34 lines (28 loc) · 998 Bytes
/
Solution.cs
File metadata and controls
34 lines (28 loc) · 998 Bytes
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
30
31
32
33
34
namespace LeetCode.Problem1886{
//1886. Determine Whether Matrix Can Be Obtained By Rotation
//https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation/
/*
Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating
mat in 90-degree increments, or false otherwise.
*/
public class Solution {
public bool FindRotation(int[][] mat, int[][] target) {
int[][] comparing = new int[mat.Length][];
for (int steps = 0; steps < 4; steps++)
{
int equals = 0;
for (int i = 0; i < mat.Length; i++)
{
comparing[i] = mat.Select(p => p[i]).Reverse().ToArray();
if (comparing[i].SequenceEqual(target[i]))
{
equals++;
}
}
if (equals == comparing.Length) return true;
Array.Copy(comparing,mat,mat.Length);
}
return false;
}
}
}