Shortest Bridge

Problem: Shortest Bridge

Given an n x n binary matrix grid:

  • 1 represents land;
  • 0 represents water;
  • there are exactly two islands in the grid.

An island is a group of 1s connected...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: