ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://leetcode.com/problems/sudoku-solver/ |
| Last Crawled | 2026-04-05 18:12:12 (1 day ago) |
| First Indexed | 2015-03-09 13:09:44 (11 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Sudoku Solver - LeetCode |
| Meta Description | Can you solve this real interview question? Sudoku Solver - Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: 1. Each of the digits 1-9 must occur exactly once in each row. 2. Each of the digits 1-9 must occur exactly once in each column. 3. Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid. The '.' character indicates empty cells. Example 1: [https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Sudoku-by-L2G-20050714.svg/250px-Sudoku-by-L2G-20050714.svg.png] 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: [["5","3","4","6","7","8","9","1","2"],["6","7","2","1","9","5","3","4","8"],["1","9","8","3","4","2","5","6","7"],["8","5","9","7","6","1","4","2","3"],["4","2","6","8","5","3","7","9","1"],["7","1","3","9","2","4","8","5","6"],["9","6","1","5","3","7","2","8","4"],["2","8","7","4","1","9","6","3","5"],["3","4","5","2","8","6","1","7","9"]] Explanation: The input board is shown above and the only valid solution is shown below: [https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Sudoku-by-L2G-20050714_solution.svg/250px-Sudoku-by-L2G-20050714_solution.svg.png] Constraints: * board.length == 9 * board[i].length == 9 * board[i][j] is a digit or '.'. * It is guaranteed that the input board has only one solution. |
| Meta Canonical | null |
| Boilerpipe Text | Write a program to solve a Sudoku puzzle by filling the empty cells.
A sudoku solution must satisfy
all of the following rules
:
Each of the digits
1-9
must occur exactly once in each row.
Each of the digits
1-9
must occur exactly once in each column.
Each of the digits
1-9
must occur exactly once in each of the 9
3x3
sub-boxes of the grid.
The
'.'
character indicates empty cells.
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:
[["5","3","4","6","7","8","9","1","2"],["6","7","2","1","9","5","3","4","8"],["1","9","8","3","4","2","5","6","7"],["8","5","9","7","6","1","4","2","3"],["4","2","6","8","5","3","7","9","1"],["7","1","3","9","2","4","8","5","6"],["9","6","1","5","3","7","2","8","4"],["2","8","7","4","1","9","6","3","5"],["3","4","5","2","8","6","1","7","9"]]
Explanation:
The input board is shown above and the only valid solution is shown below:
Constraints:
board.length == 9
board[i].length == 9
board[i][j]
is a digit or
'.'
.
It is
guaranteed
that the input board has only one solution. |
| Markdown | 

Debugging...
Submit
00:00:00
[Register](https://leetcode.com/accounts/signup/?next=%2Fproblems%2Fsudoku-solver%2Fdescription%2F)or[Log in](https://leetcode.com/accounts/login/?next=%2Fproblems%2Fsudoku-solver%2Fdescription%2F)
[Premium](https://leetcode.com/subscribe/?ref=lp_pl&source=qd)
Description
Description
Editorial
Editorial
Solutions
Solutions
Submissions
Submissions
Code
Code
Testcase
Testcase
Test Result
Test Result
[37\. Sudoku Solver](https://leetcode.com/problems/sudoku-solver/)
Hard
Topics
Companies
Hint
Write a program to solve a Sudoku puzzle by filling the empty cells.
A sudoku solution must satisfy **all of the following rules**:
1. Each of the digits `1-9` must occur exactly once in each row.
2. Each of the digits `1-9` must occur exactly once in each column.
3. Each of the digits `1-9` must occur exactly once in each of the 9 `3x3` sub-boxes of the grid.
The `'.'` character indicates empty cells.
**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: [["5","3","4","6","7","8","9","1","2"],["6","7","2","1","9","5","3","4","8"],["1","9","8","3","4","2","5","6","7"],["8","5","9","7","6","1","4","2","3"],["4","2","6","8","5","3","7","9","1"],["7","1","3","9","2","4","8","5","6"],["9","6","1","5","3","7","2","8","4"],["2","8","7","4","1","9","6","3","5"],["3","4","5","2","8","6","1","7","9"]]
Explanation: The input board is shown above and the only valid solution is shown below:
```
**Constraints:**
- `board.length == 9`
- `board[i].length == 9`
- `board[i][j]` is a digit or `'.'`.
- It is **guaranteed** that the input board has only one solution.
Accepted
1,018,909/1.6M
Acceptance Rate
65\.4%
***
Topics
[Array](https://leetcode.com/tag/array/)[Hash Table](https://leetcode.com/tag/hash-table/)[Backtracking](https://leetcode.com/tag/backtracking/)[Matrix](https://leetcode.com/tag/matrix/)
***

Companies
***
Hint 1
For each cell, place a valid number and try solving for the remaining empty cells.
***
Hint 2
If stuck, undo (backtrack) and try another valid number.
***
Similar Questions
[Valid Sudoku](https://leetcode.com/problems/valid-sudoku/)
Medium
[Unique Paths III](https://leetcode.com/problems/unique-paths-iii/)
Hard
***
Discussion (279)
Choose a type
Comment
💡 Discussion Rules
1\. Please don't post **any solutions** in this discussion.
2\. The problem discussion is for asking questions about the problem or for sharing tips - anything except for solutions.
3\. If you'd like to share your solution for feedback and ideas, please head to the solutions tab and post it there.
Sort by:Best
No comments yet.
1
2
3
4
28
Copyright © 2026 LeetCode. All rights reserved.
11\.1K
279
115 Online
1
Ln 1, Col 1
Case 1
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"\]\]
9
1
›
\[\["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"\]\]
Source
FindHeaderBarSize
FindTabBarSize
FindBorderBarSize |
| Readable Markdown | Write a program to solve a Sudoku puzzle by filling the empty cells.
A sudoku solution must satisfy **all of the following rules**:
1. Each of the digits `1-9` must occur exactly once in each row.
2. Each of the digits `1-9` must occur exactly once in each column.
3. Each of the digits `1-9` must occur exactly once in each of the 9 `3x3` sub-boxes of the grid.
The `'.'` character indicates empty cells.
**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: [["5","3","4","6","7","8","9","1","2"],["6","7","2","1","9","5","3","4","8"],["1","9","8","3","4","2","5","6","7"],["8","5","9","7","6","1","4","2","3"],["4","2","6","8","5","3","7","9","1"],["7","1","3","9","2","4","8","5","6"],["9","6","1","5","3","7","2","8","4"],["2","8","7","4","1","9","6","3","5"],["3","4","5","2","8","6","1","7","9"]]
Explanation: The input board is shown above and the only valid solution is shown below:
```
**Constraints:**
- `board.length == 9`
- `board[i].length == 9`
- `board[i][j]` is a digit or `'.'`.
- It is **guaranteed** that the input board has only one solution. |
| Shard | 99 (laksa) |
| Root Hash | 17128001481954483899 |
| Unparsed URL | com,leetcode!/problems/sudoku-solver/ s443 |