Question: Write in python 3 please Regions in Grid 1 & 2 Regions There are 2 regions in the second grid: { ( 0 , 0

Write in python3 please
Regions in Grid 1 & 2
Regions
There are 2 regions in the second grid: {(0,0),(0,1),(0,2),(1,0),(2,0)} and {(2,2)}.
Regions in grid 1 cover the first region of grid 2, but not the second region. There is 1 matching region.
Making a slight alteration to the above example:
111111
101100
100101
There are no matching regions. From the first graph, the 1 at position (1,2) is not matched in the second
grid's larger region. The second grid position (2,2) is not matched in grid 1.
Function Description
Complete the function countMatches in the editor below.
countMatches has the following parameter(s):
string grid1[n]: an array of bit strings representing the rows of image 1
string grid2[n]: an array of bit strings representing the rows of image 2
Returns:
int: number of matching regions.
Constraints
1n100
1 lengths of grid1[i] and grid2[i]100
grid cells contain only o or 1
Input Format For Custom Testing
Sample Case 0
Sample Input 0
)')'
Sample Output 0
1
Expianation 0
Regions in Grid 1 & 2
Regions
The first grid forms 2 regions. They are {(0,2),(1,1),(1,2)} and {(2,0)}
The second grid forms 2 regions. They are {(0,2),(1,1),(1,2),(2,2)} and {(2,0)}
So, only one region matches.
 Write in python3 please Regions in Grid 1 & 2 Regions

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 Databases Questions!