Class Solution
-
- All Implemented Interfaces:
public final class Solution2133 - Check if Every Row and Column Contains All Numbers.
Easy
An
n x nmatrix is valid if every row and every column contains all the integers from1ton( inclusive ).Given an
n x ninteger matrixmatrix, returntrueif the matrix is valid. Otherwise, returnfalse.Example 1:
Input: matrix = [1,2,3,3,1,2,2,3,1]
Output: true
Explanation: In this case, n = 3, and every row and column contains the numbers 1, 2, and 3. Hence, we return true.
Example 2:
Input: matrix = [1,1,1,1,2,3,1,2,3]
Output: false
Explanation: In this case, n = 3, but the first row and the first column do not contain the numbers 2 or 3. Hence, we return false.
Constraints:
n == matrix.length == matrix[i].length1 <= n <= 1001 <= matrix[i][j] <= n
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleancheckValid(Array<IntArray> matrix)-
-
Method Detail
-
checkValid
final Boolean checkValid(Array<IntArray> matrix)
-
-
-
-