【Amazon面经】Number of Islands 其他公司 OA 电面 开发岗

兔精精 2020-5-14 846


Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

Example 1:

Input:

11110 11010 11000 00000

Output: 1

Example 2:

Input:

11000 11000 00100 00011

Output: 3

最后于 2020-6-1 被maomoke编辑 ,原因:
最新回复 (0)
返回