Skip to content

Commit cf2a867

Browse files
authored
Create 1886. Determine Whether Matrix Can Be Obtained By Rotation.py
1 parent d1dc867 commit cf2a867

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
-
6+
7+
2. 시간복잡도 :
8+
O(n * m)
9+
10+
3. 자료구조/알고리즘 :
11+
-
12+
13+
'''
14+
class Solution:
15+
def findRotation(self, mat: List[List[int]], target: List[List[int]]) -> bool:
16+
n = len(mat)
17+
m = len(mat[0])
18+
# 0, 90, 180, 270
19+
ans = [1, 1, 1, 1]
20+
for row in range(n):
21+
for col in range(m):
22+
if mat[row][col] != target[row][col]:
23+
ans[0] = 0
24+
if mat[row][col] != target[col][n-row-1]:
25+
ans[1] = 0
26+
if mat[row][col] != target[n-row-1][m-col-1]:
27+
ans[2] = 0
28+
if mat[row][col] != target[n-col-1][row]:
29+
ans[3] = 0
30+
31+
return sum(ans) >= 1
32+

0 commit comments

Comments
 (0)