当前位置:网站首页>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);
}
};
边栏推荐
- 【obs】Impossible to find entrance point CreateDirect3D11DeviceFromDXGIDevice
- 5g NR system messages
- Huawei switch s5735s-l24t4s-qa2 cannot be remotely accessed by telnet
- Introduction to paddle - using lenet to realize image classification method I in MNIST
- QT establish signal slots between different classes and transfer parameters
- 韦东山第二期课程内容概要
- 【obs】官方是配置USE_GPU_PRIORITY 效果为TRUE的
- Service Mesh的基本模式
- Analysis of 8 classic C language pointer written test questions
- Summary of weidongshan phase II course content
猜你喜欢
9. Introduction to convolutional neural network
Lecture 1: the entry node of the link in the linked list
They gathered at the 2022 ecug con just for "China's technological power"
letcode43:字符串相乘
完整的模型验证(测试,demo)套路
第一讲:链表中环的入口结点
4.交叉熵
10.CNN应用于手写数字识别
What has happened from server to cloud hosting?
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
随机推荐
13. Model saving and loading
基础篇——整合第三方技术
Course of causality, taught by Jonas Peters, University of Copenhagen
Leetcode brush questions
[OBS] the official configuration is use_ GPU_ Priority effect is true
Analysis of 8 classic C language pointer written test questions
Introduction to paddle - using lenet to realize image classification method II in MNIST
Semantic segmentation model base segmentation_ models_ Detailed introduction to pytorch
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
Summary of weidongshan phase II course content
Basic mode of service mesh
Basic types of 100 questions for basic grammar of Niuke
LeetCode刷题
9.卷积神经网络介绍
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
letcode43:字符串相乘
8道经典C语言指针笔试题解析
基于卷积神经网络的恶意软件检测方法
German prime minister says Ukraine will not receive "NATO style" security guarantee
接口测试要测试什么?