Shortest bridge

0
Remix

A grid holds exactly two islands. Return the fewest water cells to flip to connect them: mark one island with depth-first search, then expand from all its cells with breadth-first search until you reach the other.

MetaTechnical phone screenLast asked Jul 2025
No answer yet. Write the first one; the best answer gets endorsed.