Welcome to the daily solving of our PROBLEM OF THE DAY with Ayush Tripathi. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Matrix but also build up problem-solving skills.
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.
Examples:
Input:
matrix = [[0, 1, 0],
[0, 1, 1],
[0, 0, 0]]
Output: 6
Explanation: There are a total of 6 coverage are there.
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/coverage-of-all-zeros-in-a-binary-matrix4024/1