Leetcode 934. Shortest Bridge
Given an n×n binary grid containing exactly two 4-connected islands, return the minimum number of 0→1 flips needed to connect them. The core challenge is finding the shortest bridge between island boundaries (commonly solved by marking one island and doing a multi-source BFS outward across water until the other island is reached).
Asked at:
Meta

Microsoft
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early August, 2025

Microsoft
Senior
Late January, 2025
Meta
Mid-level
Late January, 2025
Meta
Mid-level
You are given an n x n binary matrix grid where 1 represents land and 0 represents water. An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid. You may change 0's to 1's to connect the two islands to form one island. Return the smallest number of 0's you must flip to connect the two islands.
Your account is free and you can post anonymously if you choose.