当前位置:网站首页>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);
}
};
边栏推荐
- Codeforces Round #804 (Div. 2)(A~D)
- Service mesh introduction, istio overview
- After going to ByteDance, I learned that there are so many test engineers with an annual salary of 40W?
- Kubernetes static pod (static POD)
- A network composed of three convolution layers completes the image classification task of cifar10 data set
- 5g NR system messages
- Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
- Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
- 基于微信小程序开发的我最在行的小游戏
- 炒股开户怎么最方便,手机上开户安全吗
猜你喜欢
Lecture 1: the entry node of the link in the linked list
QT establish signal slots between different classes and transfer parameters
基于人脸识别实现课堂抬头率检测
Prediction of the victory or defeat of the League of heroes -- simple KFC Colonel
Letcode43: string multiplication
4.交叉熵
Invalid V-for traversal element style
13.模型的保存和载入
第一讲:链表中环的入口结点
[OBS] the official configuration is use_ GPU_ Priority effect is true
随机推荐
接口测试进阶接口脚本使用—apipost(预/后执行脚本)
3.MNIST数据集分类
Marubeni official website applet configuration tutorial is coming (with detailed steps)
QT establish signal slots between different classes and transfer parameters
Class head up rate detection based on face recognition
Summary of weidongshan phase II course content
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
韦东山第三期课程内容概要
Basic mode of service mesh
国外众测之密码找回漏洞
German prime minister says Ukraine will not receive "NATO style" security guarantee
Image data preprocessing
Lecture 1: the entry node of the link in the linked list
From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
Interface test advanced interface script use - apipost (pre / post execution script)
Letcode43: string multiplication
DNS series (I): why does the updated DNS record not take effect?
3 years of experience, can't you get 20K for the interview and test post? Such a hole?
12.RNN应用于手写数字识别
A network composed of three convolution layers completes the image classification task of cifar10 data set