1886. Determine Whether Matrix Can Be Obtained By Rotation Easy

@problem@discussion
#Array#Matrix



1/**
2 * [1886] Determine Whether Matrix Can Be Obtained By Rotation
3 *
4 * 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.
5 *  
6 * Example 1:
7 * <img alt="" src="https://assets.leetcode.com/uploads/2021/05/20/grid3.png" style="width: 301px; height: 121px;" />
8 * Input: mat = [[0,1],[1,0]], target = [[1,0],[0,1]]
9 * Output: true
10 * Explanation: We can rotate mat 90 degrees clockwise to make mat equal target.
11 * 
12 * Example 2:
13 * <img alt="" src="https://assets.leetcode.com/uploads/2021/05/20/grid4.png" style="width: 301px; height: 121px;" />
14 * Input: mat = [[0,1],[1,1]], target = [[1,0],[0,1]]
15 * Output: false
16 * Explanation: It is impossible to make mat equal to target by rotating mat.
17 * 
18 * Example 3:
19 * <img alt="" src="https://assets.leetcode.com/uploads/2021/05/26/grid4.png" style="width: 661px; height: 184px;" />
20 * Input: mat = [[0,0,0],[0,1,0],[1,1,1]], target = [[1,1,1],[0,1,0],[0,0,0]]
21 * Output: true
22 * Explanation: We can rotate mat 90 degrees clockwise two times to make mat equal target.
23 * 
24 *  
25 * Constraints:
26 * 
27 * 	n == mat.length == target.length
28 * 	n == mat[i].length == target[i].length
29 * 	1 <= n <= 10
30 * 	mat[i][j] and target[i][j] are either 0 or 1.
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation/
36// discuss: https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn find_rotation(mat: Vec<Vec<i32>>, target: Vec<Vec<i32>>) -> bool {
42        false
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_1886() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.