Question: You are given a rectangular grid of 0 s and 1 s , where the 0 s represent water and the 1 s represent land.

You are given a rectangular grid of 0s and 1s, where the 0s represent water and the 1s represent land. A land-cell
is connected to another if the two are adjacent (horizontally, vertically and diagonally). All the land-cells that are
connected in this manner form an island and the number of land-cells in the island define the island size. In the
following example, there are a total of 6 islands, their sizes being 2,4,5,7,11 and 12.
Every island is connected via bridges to the smallest island larger than itself and to the largest island smaller
than itself. In addition, there is a bridge between two islands if their sizes have the same sum-of-digits. In the
example, there are bridges between the islands

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!