← 返回 amazon 的题目列表Shortest Distance Between Two Islands
类型:online_judge
Given a 2D grid of 0's (water) and 1's (land), find the shortest distance between two islands. An island is formed by connecting adjacent lands horizontally or vertically. Return the length of the shortest bridge connecting them.
Example
Input
2
[0,1,0,0,0]
[0,1,0,1,1]