js-practice/test/array/number-of-islands.test.js

18 lines
321 B
JavaScript
Raw Normal View History

2019-03-10 16:43:04 +08:00
import { numIslands } from '../../src/array/number-of-islands'
test('岛屿的个数', () => {
expect(numIslands([
[1, 1, 0, 0, 0],
[0, 1, 0, 0, 1],
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 1]
])).toBe(3)
expect(numIslands([
[1, 1]
])).toBe(1)
expect(numIslands([])).toBe(0)
})