Skip to content

Practice Check if Every Row and Column Contains All Numbers

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

Easy#2133
LeetCode Problem

Check if Every Row and Column Contains All Numbers

Problem Statement

An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive). Given an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.

Source: Check if Every Row and Column Contains All Numbers on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
matrix = [[1,2,3],[3,1,2],[2,3,1]]
Output
true

# Example 2

Input
matrix = [[1,1,1],[1,2,3],[1,2,3]]
Output
false

Constraints

n == matrix.length == matrix[i].length
1 <= n <= 100
1 <= matrix[i][j] <= n

Related LeetCode Problems

Practice more problems similar to Check if Every Row and Column Contains All Numbers.

Review your practice with PhantomCodeAI

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