Skip to content

Commit

Permalink
Fixed Formatting 0130-surrounded-regions.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ykhan799 authored Sep 29, 2024
1 parent d950e8e commit 139261e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions cpp/0130-surrounded-regions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class Solution {
q.push({row, col});

vector<pair<int, int>> directions = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
while(!q.empty()) {
while (!q.empty()) {
auto [r, c] = q.front();
q.pop();
for(const auto &direction : directions) {
for (const auto &direction : directions) {
int newRow = r + direction.first;
int newCol = c + direction.second;
if(newRow < rows && newRow >= 0 && newCol < cols && newCol >= 0 && board[newRow][newCol] == 'O') {
if (newRow < rows && newRow >= 0 && newCol < cols && newCol >= 0 && board[newRow][newCol] == 'O') {
board[newRow][newCol] = 'E';
q.push({newRow, newCol});
}
Expand All @@ -85,26 +85,26 @@ class Solution {
rows = board.size();
cols = board[0].size();

for(int row = 0; row < rows; ++row) {
if(board[row][0] == 'O') bfs(row, 0, board);
if(board[row][cols - 1] == 'O') bfs(row, cols - 1, board);
for (int row = 0; row < rows; ++row) {
if (board[row][0] == 'O') bfs(row, 0, board);
if (board[row][cols - 1] == 'O') bfs(row, cols - 1, board);
}

for(int col = 0; col < cols; ++col) {
if(board[0][col] == 'O') bfs(0, col, board);
if(board[rows - 1][col] == 'O') bfs(rows - 1, col, board);
for (int col = 0; col < cols; ++col) {
if (board[0][col] == 'O') bfs(0, col, board);
if (board[rows - 1][col] == 'O') bfs(rows - 1, col, board);
}

for(int row = 0; row < rows; ++row) {
for(int col = 0; col < cols; ++col) {
if(board[row][col] == 'O') {
for (int row = 0; row < rows; ++row) {
for (int col = 0; col < cols; ++col) {
if (board[row][col] == 'O') {
board[row][col] = 'X';
}
else if(board[row][col] == 'E') {
else if (board[row][col] == 'E') {
board[row][col] = 'O';
}
}
}

}
};
};

0 comments on commit 139261e

Please sign in to comment.