#include <leetcode.h>
|
static void | solveSudoku (vector< vector< char > > &board) |
|
|
static bool | dfs (const vector< vector< char > > &board, vector< vector< char > > &ans) |
|
static bool | valid (const vector< vector< char > > &board, int x, int y, char num) |
|
◆ dfs()
bool leetcode::sudoku_solver::Solution::dfs |
( |
const vector< vector< char > > & | board, |
|
|
vector< vector< char > > & | ans ) |
|
staticprivate |
在文件 leetcode.cpp 第 8364 行定义.
8364 {
8365 for(int i = 0; i < 9; i++) {
8366 for(int j = 0; j < 9; j++) {
8367 if(board[i][j] == '.') {
8368 for(char c = '1'; c <= '9'; c++) {
8369 if(
valid(board, i, j, c)) {
8370 bool haveValid = true;
8371 vector<vector<char>> next = board;
8372 next[i][j] = c;
8373 if(
dfs(next, ans)) {
8374 return true;
8375 }
8376 }
8377 }
8378 return false;
8379 }
8380 }
8381 }
8383 return true;
8384 }
vector< vector< int > > ans
static bool valid(const vector< vector< char > > &board, int x, int y, char num)
static bool dfs(const vector< vector< char > > &board, vector< vector< char > > &ans)
引用了 dfs() , 以及 valid().
被这些函数引用 dfs() , 以及 solveSudoku().
◆ solveSudoku()
void leetcode::sudoku_solver::Solution::solveSudoku |
( |
vector< vector< char > > & | board | ) |
|
|
static |
◆ valid()
bool leetcode::sudoku_solver::Solution::valid |
( |
const vector< vector< char > > & | board, |
|
|
int | x, |
|
|
int | y, |
|
|
char | num ) |
|
staticprivate |
在文件 leetcode.cpp 第 8386 行定义.
8386 {
8387 for(int i = 0; i < 9; i++) {
8388 if(board[i][y] == num) {
8389 return false;
8390 }
8391 }
8392 for(int j = 0; j < 9; j++) {
8393 if(board[x][j] == num) {
8394 return false;
8395 }
8396 }
8397 for(int i = 0; i < 3; i++) {
8398 for(int j = 0; j < 3; j++) {
8399 if(board[x / 3 * 3 + i][y / 3 * 3 + j] == num) {
8400 return false;
8401 }
8402 }
8403 }
8404 return true;
8405 }
被这些函数引用 dfs().
该类的文档由以下文件生成: