LeetCode 1886. Determine Whether Matrix Can Be Obtained By Rotation
考点 | 难度 |
---|---|
Matrix | Easy |
题目
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.
思路
分别转90、180、270度,判断有没有和target
一样的matrix。比较matrix用deepEquals( )
答案
public boolean findRotation(int[][] mat, int[][] target) {
int n = mat.length;
int[] res[] = new int[n][n];
for (int i = 0; i < n; i++) { //clockwise 90
for (int j = 0; j < n; j++) {
re