Shortest Bridge
Medium · Graphs · about 25 minutes
Asked at Meta, Uber, Google, ByteDance, Snowflake.
An n × n binary grid contains exactly two islands (4-directionally connected 1s). Return the smallest number of 0s you must flip to 1 to connect them into one island.