2133. Check if Every Row and Column Contains All Numbers Easy

@problem@discussion
#Array#Hash Table#Matrix



1/**
2 * [2133] Check if Every Row and Column Contains All Numbers
3 *
4 * An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).
5 * Given an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.
6 *  
7 * Example 1:
8 * <img alt="" src="https://assets.leetcode.com/uploads/2021/12/21/example1drawio.png" style="width: 250px; height: 251px;" />
9 * Input: matrix = [[1,2,3],[3,1,2],[2,3,1]]
10 * Output: true
11 * Explanation: In this case, n = 3, and every row and column contains the numbers 1, 2, and 3.
12 * Hence, we return true.
13 * 
14 * Example 2:
15 * <img alt="" src="https://assets.leetcode.com/uploads/2021/12/21/example2drawio.png" style="width: 250px; height: 251px;" />
16 * Input: matrix = [[1,1,1],[1,2,3],[1,2,3]]
17 * Output: false
18 * Explanation: In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3.
19 * Hence, we return false.
20 * 
21 *  
22 * Constraints:
23 * 
24 * 	n == matrix.length == matrix[i].length
25 * 	1 <= n <= 100
26 * 	1 <= matrix[i][j] <= n
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers/
32// discuss: https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn check_valid(matrix: Vec<Vec<i32>>) -> bool {
38        false
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_2133() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.