You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solutions/1-1000/200-number-of-islands-2.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ class Solution:
118
118
ifself.grid[i][j] !='1':
119
119
continue
120
120
121
-
self.grid[i][j] ='V'
121
+
self.grid[i][j] ='V'# For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as pushing `vertex_stack`. Because the adjacent veticies could be a lot, and it will cause performance issue.
122
122
123
123
self.vertex_stack.append((i, j -1))
124
124
self.vertex_stack.append((i +1, j))
@@ -169,7 +169,7 @@ class Solution {
169
169
continue;
170
170
}
171
171
172
-
grid[i][j] ='V';
172
+
grid[i][j] ='V';// For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as pushing `vertex_stack`. Because the adjacent veticies could be a lot, and it will cause performance issue.
173
173
174
174
vertexStack.push(newint[]{i, j -1});
175
175
vertexStack.push(newint[]{i +1, j});
@@ -209,7 +209,7 @@ private:
209
209
continue;
210
210
}
211
211
212
-
grid_[i][j] = 'V';
212
+
grid_[i][j] = 'V'; // For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as pushing `vertex_stack`. Because the adjacent veticies could be a lot, and it will cause performance issue.
213
213
214
214
vertex_stack.push({i, j - 1});
215
215
vertex_stack.push({i + 1, j});
@@ -279,7 +279,7 @@ function depthFirstSearch(vertex) {
279
279
continue
280
280
}
281
281
282
-
grid[i][j] ='V';
282
+
grid[i][j] ='V';// For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as pushing `vertex_stack`. Because the adjacent veticies could be a lot, and it will cause performance issue.
283
283
284
284
vertexStack.push([i, j -1])
285
285
vertexStack.push([i +1, j])
@@ -340,7 +340,7 @@ public class Solution
340
340
continue;
341
341
}
342
342
343
-
grid[i][j] ='V';
343
+
grid[i][j] ='V';// For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as pushing `vertex_stack`. Because the adjacent veticies could be a lot, and it will cause performance issue.
grid[i][j] = 'V'// For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as pushing `vertex_stack`. Because the adjacent veticies could be a lot, and it will cause performance issue.
@grid[i][j] ='V'# For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as pushing `vertex_stack`. Because the adjacent veticies could be a lot, and it will cause performance issue.
Copy file name to clipboardExpand all lines: solutions/1-1000/200-number-of-islands-3.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,7 +108,7 @@ class Solution:
108
108
ifself.grid[i][j] !='1':
109
109
continue
110
110
111
-
self.grid[i][j] ='V'
111
+
self.grid[i][j] ='V'# For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as enqueuing `vertex_queue`. Because the adjacent veticies could be a lot, and it will cause performance issue.
112
112
113
113
self.vertex_queue.append((i -1, j))
114
114
self.vertex_queue.append((i, j +1))
@@ -159,7 +159,7 @@ class Solution {
159
159
continue;
160
160
}
161
161
162
-
grid[i][j] ='V';
162
+
grid[i][j] ='V';// For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as enqueuing `vertex_queue`. Because the adjacent veticies could be a lot, and it will cause performance issue.
163
163
164
164
vertexQueue.add(newint[]{i -1, j});
165
165
vertexQueue.add(newint[]{i, j +1});
@@ -199,7 +199,7 @@ private:
199
199
continue;
200
200
}
201
201
202
-
grid_[i][j] = 'V';
202
+
grid_[i][j] = 'V'; // For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as enqueuing `vertex_queue`. Because the adjacent veticies could be a lot, and it will cause performance issue.
203
203
204
204
vertex_queue.push({i - 1, j});
205
205
vertex_queue.push({i, j + 1});
@@ -269,7 +269,7 @@ function breadthFirstSearch(vertex) {
269
269
continue
270
270
}
271
271
272
-
grid[i][j] ='V';
272
+
grid[i][j] ='V';// For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as enqueuing `vertex_queue`. Because the adjacent veticies could be a lot, and it will cause performance issue.
273
273
274
274
vertexQueue.enqueue([i -1, j])
275
275
vertexQueue.enqueue([i, j +1])
@@ -332,7 +332,7 @@ public class Solution
332
332
continue;
333
333
}
334
334
335
-
grid[i][j] ='V';
335
+
grid[i][j] ='V';// For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as enqueuing `vertex_queue`. Because the adjacent veticies could be a lot, and it will cause performance issue.
grid[i][j] = 'V'// For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as enqueuing `vertex_queue`. Because the adjacent veticies could be a lot, and it will cause performance issue.
@grid[i][j] ='V'# For island problems, its OK to mark visited at this place. For other graph problems, we need to use `visited_vertex_set` and mark visited as soon as enqueuing `vertex_queue`. Because the adjacent veticies could be a lot, and it will cause performance issue.
0 commit comments