Skip to content

Commit aab634e

Browse files
refactor 200
1 parent 9aa6518 commit aab634e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
public class _200 {
2828

29-
public static class DFSSolution {
29+
public static class Solution1 {
3030

3131
public int numIslands(char[][] grid) {
3232
if (grid == null || grid.length == 0) {
@@ -58,7 +58,7 @@ void dfs(char[][] grid, int i, int j, int m, int n) {
5858
}
5959
}
6060

61-
public static class UnionFindSolution {
61+
public static class Solution2 {
6262

6363
class UnionFind {
6464
int count;

src/test/java/com/fishercoder/_200Test.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
import static org.junit.Assert.assertEquals;
88

99
public class _200Test {
10-
private static _200.DFSSolution dfsSolution;
11-
private static _200.UnionFindSolution unionFindSolution;
10+
private static _200.Solution1 solution1;
11+
private static _200.Solution2 solution2;
1212
private static char[][] grid;
1313

1414
@Before
1515
public void setup() {
16-
dfsSolution = new _200.DFSSolution();
17-
unionFindSolution = new _200.UnionFindSolution();
16+
solution1 = new _200.Solution1();
17+
solution2 = new _200.Solution2();
1818
}
1919

2020
@Test
@@ -24,14 +24,14 @@ public void test1() {
2424
{'0', '1', '0'},
2525
{'1', '1', '1'},
2626
};
27-
assertEquals(1, dfsSolution.numIslands(grid));
27+
assertEquals(1, solution1.numIslands(grid));
2828

2929
grid = new char[][]{
3030
{'1', '1', '1'},
3131
{'0', '1', '0'},
3232
{'1', '1', '1'},
3333
};
34-
assertEquals(1, unionFindSolution.numIslands(grid));
34+
assertEquals(1, solution2.numIslands(grid));
3535
}
3636

3737
@Test
@@ -42,15 +42,15 @@ public void test2() {
4242
{'1', '1', '0', '0', '0'},
4343
{'0', '0', '0', '0', '0'},
4444
};
45-
assertEquals(1, dfsSolution.numIslands(grid));
45+
assertEquals(1, solution1.numIslands(grid));
4646

4747
grid = new char[][]{
4848
{'1', '1', '1', '1', '0'},
4949
{'1', '1', '0', '1', '0'},
5050
{'1', '1', '0', '0', '0'},
5151
{'0', '0', '0', '0', '0'},
5252
};
53-
assertEquals(1, unionFindSolution.numIslands(grid));
53+
assertEquals(1, solution2.numIslands(grid));
5454
}
5555

5656
@Test
@@ -61,15 +61,15 @@ public void test3() {
6161
{'0', '0', '1', '0', '0'},
6262
{'0', '0', '0', '1', '1'},
6363
};
64-
assertEquals(3, dfsSolution.numIslands(grid));
64+
assertEquals(3, solution1.numIslands(grid));
6565

6666
grid = new char[][]{
6767
{'1', '1', '0', '0', '0'},
6868
{'1', '1', '0', '0', '0'},
6969
{'0', '0', '1', '0', '0'},
7070
{'0', '0', '0', '1', '1'},
7171
};
72-
assertEquals(3, unionFindSolution.numIslands(grid));
72+
assertEquals(3, solution2.numIslands(grid));
7373
}
7474

7575
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy