Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6381
@blackshadows 6329
@mb1973 5388
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3357
@KshamaGupta 3318
Complete Leaderboard
Coverage of all Zeros in a Binary Matrix
Easy Accuracy: 29.54% Submissions: 34 Points: 2

Given a binary matrix  having n rows and m columns, your task is to find the sum of coverage of all zeros in the matrix where coverage for a particular 0 is defined as total number of ones around a zero in left, right, up and bottom directions.
 

Example 1:

Input: matrix = {{0, 1, 0},
{0, 1, 1}, {0, 0, 0}}
Output: 6

Example 2:

Input: matrix = {{0, 1}}
Output: 1

 

Your Task:
You don't need to read or print anyhting. Your task is to complete the function FindCoverage() which takes the matrix as input parameter and returns sum of coverage of all zeros in the matrix.

 

Expected Time Complexity: O(n m)
Expected Space Complexity: O(1)

 

Constraints:
1 <= n, m <= 100

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Coverage of all Zeros in a Binary Matrix

Output Window