Skip to content

Latest commit

 

History

History

26-06-2024

Go To Problem

Coverage of all Zeros in a Binary Matrix

Easy
Accuracy: 55.68% Points: 2

Given a binary matrix contains 0s and 1s only, we need to find the sum of coverage of all zeros of the matrix where coverage for a particular 0 is defined as a 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
Explanation:
      There are a total of 6 coverage are there

💡Example 2:

Input:
  matrix = [[0, 1]]
Output: 
   1
Explanation: 
    There are only 1 coverage.

Expected Time Complexity:

O(n * m)

Expected Space Complexity:

O(1)

Constraints:

1 <= matrix.size, matrix[0].size <= 100

Topic Tags:

Codes: