Skip to content

Commit bb46ef1

Browse files
update 200
1 parent 122596c commit bb46ef1

File tree

1 file changed

+18
-16
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+18
-16
lines changed

src/main/java/com/fishercoder/solutions/_200.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,33 @@
22

33
/**
44
* 200. Number of Islands
5-
*
5+
* <p>
66
* Given a 2d grid map of '1's (land) and '0's (water),
77
* count the number of islands.
88
* An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
99
* You may assume all four edges of the grid are all surrounded by water.
10-
11-
Example 1:
12-
11110
13-
11010
14-
11000
15-
00000
16-
Answer: 1
17-
18-
Example 2:
19-
11000
20-
11000
21-
00100
22-
00011
23-
Answer: 3
24-
10+
* <p>
11+
* Example 1:
12+
* 11110
13+
* 11010
14+
* 11000
15+
* 00000
16+
* Answer: 1
17+
* <p>
18+
* Example 2:
19+
* 11000
20+
* 11000
21+
* 00100
22+
* 00011
23+
* Answer: 3
2524
*/
2625
public class _200 {
2726

2827
public static class Solution1 {
2928

29+
/**
30+
* DFS solution, note: this modifies the input.
31+
*/
3032
public int numIslands(char[][] grid) {
3133
if (grid == null || grid.length == 0) {
3234
return 0;

0 commit comments

Comments
 (0)