Question: Given a 2 d grid map of ' 1 ' s ( wood ) and ' 0 ' s ( water ) , count the
Given a d grid map of s wood and s water count the boats in the sea.
A boat is surrounded by water and is formed by connecting adjacent wood horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
A single wood surrounded by water is also considered as a boat. Find the number of boats in the sea.
Let be the number of rows and be the number of columns in the grid.
Input format:
The first line consists of integers R and C
Followed by a matrix of size R x C
Output format:
Print the number of boats in a sea.
Constraints
Examples
Input:
Output:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
