2015. Determine Whether Matrix Can Be Obtained By Rotation
My accepted Python solution to LeetCode problem 2015, Determine Whether Matrix Can Be Obtained By Rotation, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.2MB, accepted 2025-12-31.
class Solution:
def findRotation(self, mat: List[List[int]], target: List[List[int]]) -> bool:
def rotate(m):
n = len(m)
return [[m[n-1-j][i] for j in range(n)] for i in range(n)]
for _ in range(4):
if mat == target:
return True
mat = rotate(mat)
return False