← 返回 apple 的题目列表Shortest Bridge (Distance Between Two Islands)
类型:qbank
You are given a binary grid containing exactly two islands, where 1 is land and 0 is water.
Examples
Example 1:
Input: grid = [[0,1],[1,0]]
Output: 1
Example 2:
Input: grid = [[0,1,0],[0,0,0],[0,0,1]]
Output: 2
Constraints
2 <= grid.length == grid[i].length <= 100
There are exactly two islands in grid.