当前位置:网站首页>130. Zones environnantes
130. Zones environnantes
2022-07-08 00:59:00 【Anieoo】
Lien vers la question originale:130. Zone entourée
solution:
dfs
class Solution {
public:
void solve(vector<vector<char>>& board) {
int m = board.size(),n = board[0].size();
for(int i = 0;i < m;i++) {
dfs(board, i, 0);
dfs(board, i, n - 1);
}
for(int j = 0;j < n;j++) {
dfs(board, 0, j);
dfs(board, m - 1, j);
}
for(int i = 0;i < m;i++)
for(int j = 0;j < n;j++) {
if(board[i][j] == '#') board[i][j] = 'O';
else if(board[i][j] == 'O') board[i][j] = 'X';
}
}
// De la frontière extérieure dfs, Pour étendre chaque ODevient#,En coursm*nTraversée,Pour le resteODevientX
void dfs(vector<vector<char>> &board, int x,int y) {
if(x < 0 || x == board.size() || y < 0 || y == board[0].size() || board[x][y] != 'O') return;
board[x][y] = '#';
dfs(board, x + 1, y);
dfs(board, x, y + 1);
dfs(board, x - 1, y);
dfs(board, x, y - 1);
}
};边栏推荐
- 4.交叉熵
- STL -- common function replication of string class
- Qt添加资源文件,为QAction添加图标,建立信号槽函数并实现
- What is load balancing? How does DNS achieve load balancing?
- Langchao Yunxi distributed database tracing (II) -- source code analysis
- Serial port receives a packet of data
- What does interface testing test?
- 13.模型的保存和载入
- Letcode43: string multiplication
- Prediction of the victory or defeat of the League of heroes -- simple KFC Colonel
猜你喜欢

5G NR 系统消息

5g NR system messages

3.MNIST数据集分类

QT adds resource files, adds icons for qaction, establishes signal slot functions, and implements

New library launched | cnopendata China Time-honored enterprise directory

FOFA-攻防挑战记录

网络模型的保存与读取

基于人脸识别实现课堂抬头率检测

接口测试进阶接口脚本使用—apipost(预/后执行脚本)

9. Introduction to convolutional neural network
随机推荐
The whole life cycle of commodity design can be included in the scope of industrial Internet
手机上炒股安全么?
国外众测之密码找回漏洞
10.CNN应用于手写数字识别
攻防演练中沙盘推演的4个阶段
v-for遍历元素样式失效
基础篇——整合第三方技术
After going to ByteDance, I learned that there are so many test engineers with an annual salary of 40W?
【obs】Impossible to find entrance point CreateDirect3D11DeviceFromDXGIDevice
9.卷积神经网络介绍
ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification
7.正则化应用
NVIDIA Jetson测试安装yolox过程记录
Invalid V-for traversal element style
Hotel
NTT template for Tourism
丸子官网小程序配置教程来了(附详细步骤)
Reentrantlock fair lock source code Chapter 0
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
【obs】官方是配置USE_GPU_PRIORITY 效果为TRUE的