Making A Large Island
Hard · Graphs · about 30 minutes
Asked at Meta, Uber, Snowflake, Amazon, Microsoft, Google, CrowdStrike, Elastic, Rubrik.
grid is an n × n grid of 0s and 1s; side-adjacent 1s form islands. You're allowed to turn one 0 into a 1, or leave the grid as it is. What is the largest island you can end up with? Return its number of cells.