Sudoku Solver

Hard
ArrayMatrixBacktrackingUberAmazon
Solve a 9 x 9 Sudoku puzzle by filling every empty cell. The solution must satisfy that each row, each column, and each of the nine 3 x 3 sub-boxes contains the digits 1-9 exactly once. Each puzzle has a unique solution. Input format: - 9 lines, each with 9 characters. A digit `1`-`9` is a filled cell and `.` is empty. Print the solved board, 9 lines of 9 digits each.

Constraints

The board is always 9 x 9.
Each cell is a digit 1-9 or the character `.`.
Exactly one solution exists.

Sample tests

Sample 1

Sample 2

Sign in to submit