Skip to content

Commit 8d22998

Browse files
fishercoder1534zhahui
authored andcommitted
refactor 37
1 parent e255227 commit 8d22998

File tree

1 file changed

+47
-3
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+47
-3
lines changed

src/main/java/com/fishercoder/solutions/_37.java

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,53 @@
33
/**
44
* 37. Sudoku Solver
55
*
6-
* Write a program to solve a Sudoku puzzle by filling the empty cells.
7-
* Empty cells are indicated by the character '.'.
8-
* You may assume that there will be only one unique solution.
6+
* Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
7+
*
8+
* Each row must contain the digits 1-9 without repetition.
9+
* Each column must contain the digits 1-9 without repetition.
10+
* Each of the 9 3x3 sub-boxes of the grid must contain the digits 1-9 without repetition.
11+
*
12+
* The Sudoku board could be partially filled, where empty cells are filled with the character '.'.
13+
*
14+
* Example 1:
15+
*
16+
* Input:
17+
* [
18+
* ["5","3",".",".","7",".",".",".","."],
19+
* ["6",".",".","1","9","5",".",".","."],
20+
* [".","9","8",".",".",".",".","6","."],
21+
* ["8",".",".",".","6",".",".",".","3"],
22+
* ["4",".",".","8",".","3",".",".","1"],
23+
* ["7",".",".",".","2",".",".",".","6"],
24+
* [".","6",".",".",".",".","2","8","."],
25+
* [".",".",".","4","1","9",".",".","5"],
26+
* [".",".",".",".","8",".",".","7","9"]
27+
* ]
28+
* Output: true
29+
* Example 2:
30+
*
31+
* Input:
32+
* [
33+
* ["8","3",".",".","7",".",".",".","."],
34+
* ["6",".",".","1","9","5",".",".","."],
35+
* [".","9","8",".",".",".",".","6","."],
36+
* ["8",".",".",".","6",".",".",".","3"],
37+
* ["4",".",".","8",".","3",".",".","1"],
38+
* ["7",".",".",".","2",".",".",".","6"],
39+
* [".","6",".",".",".",".","2","8","."],
40+
* [".",".",".","4","1","9",".",".","5"],
41+
* [".",".",".",".","8",".",".","7","9"]
42+
* ]
43+
* Output: false
44+
* Explanation: Same as Example 1, except with the 5 in the top left corner being
45+
* modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
46+
* Note:
47+
*
48+
* A Sudoku board (partially filled) could be valid but is not necessarily solvable.
49+
* Only the filled cells need to be validated according to the mentioned rules.
50+
* The given board contain only digits 1-9 and the character '.'.
51+
* The given board size is always 9x9.
52+
*
953
*/
1054
public class _37 {
1155

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy