Question: JAVASCRIPT: Bitmap Holes Have the function BitmapHoles( strArr ) take the array of strings stored in strArr , which will be a 2D matrix of

JAVASCRIPT:

Bitmap Holes

Have the function BitmapHoles(strArr) take the array of strings stored in strArr, which will be a 2D matrix of 0 and 1's, and determine how many holes, or contiguous regions of 0's, exist in the matrix. A contiguous region is one where there is a connected group of 0's going in one or more of four directions: up, down, left, or right. For example: if strArr is ["10111", "10101", "11101", "11111"], then this looks like the following matrix: 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 For the input above, your program should return 2 because there are two separate contiguous regions of 0's, which create "holes" in the matrix. You can assume the input will not be empty.

Examples

Input: ["01111", "01101", "00011", "11110"] Output: 3

Input: ["1011", "0010"] Output: 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve the problem of finding contiguous regions of 0s in a 2D matrix represented by a string array we can utilize a technique similar to the flood ... View full answer

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!