Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6379 |

@blackshadows | 6329 |

@mb1973 | 5358 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3357 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@ritiksethi21 | 1050 |

@aroranayan999 | 807 |

@RizulBansal | 685 |

@ashishtrehan002 | 538 |

@hemantgarg923 | 528 |

@simrangoyal | 526 |

@ronaldo77 | 520 |

@anishrajan | 505 |

@thanosagain | 505 |

@ssparteek470 | 495 |

@rahul2312 | 491 |

Complete Leaderboard |

Given a Binary Square Matrix where each row and column of the matrix is sorted in ascending order. Find the total number of Zeros present in the matrix.

**Input:**

The first line of input will be the no of test cases then T test cases will follow. The second line of each test case contains an integer N denoting the dimension of the matrix. Then in the next line are the space separated values of the matrix A[ ] [ ].

**Output:**

Print in a single line, the total number of zeros present in the given Binary Matrix.

**User Task:**

You don't need to read input or print anything. Your task is to complete the function **countZeros() **which takes the Binary Matrix A[][] and its size N as inputs and returns an integer denoting the total number of Zeros present in the matrix.

**Expected Time Complexity: **O(N).

**Expected Auxiliary Space: **O(1).

**Constraints:**

1<=T<=50

1<=M,N<=1000

0<=A[][]<=1

**Example:
Input**

2

3

0 0 0 0 0 1 0 1 1

2

1 1 1 1

6

4

**Note:**The **Input/Ouput** format and **Example** given are used for system's internal purpose, and should be used by a user for **Expected Output** only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

Login to report an issue on this page.

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

Yes
Count zeros in a sorted matrix

...