Skip to content

Practice Determine Whether Matrix Can Be Obtained By Rotation

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1886
LeetCode Problem

Determine Whether Matrix Can Be Obtained By Rotation

Problem Statement

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.

Source: Determine Whether Matrix Can Be Obtained By Rotation on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
mat = [[0,1],[1,0]], target = [[1,0],[0,1]]
Output
true

# Example 2

Input
mat = [[0,1],[1,1]], target = [[1,0],[0,1]]
Output
false

# Example 3

Input
mat = [[0,0,0],[0,1,0],[1,1,1]], target = [[1,1,1],[0,1,0],[0,0,0]]
Output
true

Constraints

n == mat.length == target.length
n == mat[i].length == target[i].length
1 <= n <= 10
mat[i][j] and target[i][j] are either 0 or 1.

Related LeetCode Problems

Practice more problems similar to Determine Whether Matrix Can Be Obtained By Rotation.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.