Skip to content

Commit a9e65cd

Browse files
authored
Wrapping the example matrix with outer array (TheAlgorithms#1057)
1 parent 1a089cc commit a9e65cd

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

‎Graphs/NumberOfIslands.js‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,3 @@ const islands = (matrixGrid) =>{
7979
}
8080

8181
export{islands}
82-
83-
// islands(
84-
// ['1', '1', '0', '0', '0'],
85-
// ['1', '1', '0', '0', '0'],
86-
// ['0', '0', '1', '0', '0'],
87-
// ['0', '0', '0', '1', '1']
88-
// )
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import{islands}from'../NumberOfIslands'
2+
3+
describe('Number of Islands',()=>{
4+
test('Graph with three islands',()=>{
5+
constgraph=[
6+
['1','1','0','0','0'],
7+
['1','1','0','0','0'],
8+
['0','0','1','0','0'],
9+
['0','0','0','1','1']
10+
]
11+
expect(islands(graph)).toBe(3)
12+
})
13+
14+
test('Graph with only one island',()=>{
15+
constgraph=[
16+
['1','1'],
17+
['1','1'],
18+
['0','0'],
19+
['0','0']
20+
]
21+
expect(islands(graph)).toBe(1)
22+
})
23+
24+
test('No islands',()=>{
25+
constgraph=[
26+
['0','0'],
27+
['0','0']
28+
]
29+
expect(islands(graph)).toBe(0)
30+
})
31+
})

0 commit comments

Comments
(0)