my code-https://ide.geeksforgeeks.org/Pa50ARrsfY
Problem Statement
Given a N*M binary matrix that is, it contains 0s and 1s only, we need to find and return sum of coverage of all zeros of the input matrix. Coverage for a particular 0 is defined as, total number of ones around a zero (i.e. in left, right, up and bottom directions).
Input Format :
Line 1: N and M (space-separated positive integers)
Next N lines: M elements of each row (separated by space).
Output Format :
Line 1: Print Sum Of Coverage Of All Rows
Constraints :
1 <= N <= 10^3
1 <= M <= 10^3
Time Limit : 1 sec
Sample Input 1 :
2 2
1 0
0 1
Sample Output 1 :
4
Sample Input 1 Explanation :
The 0 in first row have 2 1’s i.e. left and down, whereas 0 at second row also have 2 1’s i.e. top and right. So the total coverage value is 2 + 2 = 4.