You are given an m x n binary grid where 1 represents land and 0 represents water. The grid contains exactly two distinct islands.
You want to connect these two islands by changing a minimum number of water cells (0s) to land cells (1s). Find and return the minimum number of 0s you must flip to connect the two islands into one single component.
Visualizer will appear here