Skip to content

Practice Valid Sudoku

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

Medium#36
LeetCode Problem

Valid Sudoku

Problem Statement

Check the filled cells of a 9 by 9 Sudoku board. No digit from 1 through 9 may repeat within a row, a column or any of the nine 3 by 3 boxes. A dot (.) is an empty cell and is ignored. Return whether these rules hold; a valid partially filled board does not have to admit a complete solution.

Source: Valid Sudoku on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
board = [["5","3",".",".","7",".",".",".","."] ,["6",".",".","1","9","5",".",".","."] ,[".","9","8",".",".",".",".","6","."] ,["8",".",".",".","6",".",".",".","3"] ,["4",".",".","8",".","3",".",".","1"] ,["7",".",".",".","2",".",".",".","6"] ,[".","6",".",".",".",".","2","8","."] ,[".",".",".","4","1","9",".",".","5"] ,[".",".",".",".","8",".",".","7","9"]]
Output
true

# Example 2

Input
board = [["8","3",".",".","7",".",".",".","."] ,["6",".",".","1","9","5",".",".","."] ,[".","9","8",".",".",".",".","6","."] ,["8",".",".",".","6",".",".",".","3"] ,["4",".",".","8",".","3",".",".","1"] ,["7",".",".",".","2",".",".",".","6"] ,[".","6",".",".",".",".","2","8","."] ,[".",".",".","4","1","9",".",".","5"] ,[".",".",".",".","8",".",".","7","9"]]
Output
false

Constraints

board.length == 9
board[i].length == 9
board[i][j] is a digit 1-9 or '.'.

Related LeetCode Problems

Practice more problems similar to Valid Sudoku.

Review your practice with PhantomCodeAI

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