Shortest Bridge
CodingPhone ScreenSoftware EngineerReported Sep, 2025
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
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
You are given a binary grid containing exactly two islands, where 1 is land and 0 is water.
Return the minimum number of 0s that must be flipped to connect the two islands.
2 <= grid.length == grid[i].length <= 100grid.Reported as LeetCode 934 in a software engineer phone screen.