#include <leetcode.h>
|
static void | dfs (vector< vector< char > > &board, int x, int y) |
|
static void | solve (vector< vector< char > > &board) |
|
◆ dfs()
void leetcode::surrounded_regions::Solution::dfs |
( |
vector< vector< char > > & | board, |
|
|
int | x, |
|
|
int | y ) |
|
static |
在文件 leetcode.cpp 第 6393 行定义.
6393 {
6394 board[x][y] = 'D';
6395 const int m = board.size();
6396 const int n = board[0].size();
6397 pair<int, int> nexts[4] = {{x - 1, y}, {x + 1, y}, {x, y - 1}, {x, y + 1}};
6398 for(auto [next_x, next_y]: nexts) {
6399 if(next_x >= 0 && next_x < m && next_y >= 0 && next_y < n && board[next_x][next_y] == 'O') {
6400 dfs(board, next_x, next_y);
6401 }
6402 }
6403 }
static void dfs(vector< vector< char > > &board, int x, int y)
引用了 dfs().
被这些函数引用 dfs() , 以及 solve().
◆ solve()
void leetcode::surrounded_regions::Solution::solve |
( |
vector< vector< char > > & | board | ) |
|
|
static |
在文件 leetcode.cpp 第 6362 行定义.
6362 {
6363 const int m = board.size();
6364 const int n = board[0].size();
6365 for(
int i = 0; i <
n; i++) {
6366 if(board[0][i] == 'O') {
6368 }
6369 if(board[m - 1][i] == 'O') {
6370 dfs(board, m - 1, i);
6371 }
6372 }
6373 for(
int j = 0; j <
m; j++) {
6374 if(board[j][0] == 'O') {
6376 }
6377 if(board[j][n - 1] == 'O') {
6378 dfs(board, j, n - 1);
6379 }
6380 }
6381 for(
int i = 0; i <
m; i++) {
6382 for(
int j = 0; j <
n; j++) {
6383 if(board[i][j] == 'O') {
6384 board[i][j] = 'X';
6385 }
6386 if(board[i][j] == 'D') {
6387 board[i][j] = 'O';
6388 }
6389 }
6390 }
6391 }
引用了 dfs().
该类的文档由以下文件生成: