less than 1 minute read

You are given a two-dimensional integer matrix of 1s and 0s, where a 1 represents a bomb and 0 represents an empty cell. When a bomb explodes, all the spaces along on the same row and column are damaged. Return the number of spaces you can stand in to not get damaged.

Constraints

  • n * m ≤ 200,000 where n and m are the number of rows and columns in matrix.

https://binarysearch.com/problems/Bomber-Man

Examples

Example 1

Input

  • matrix =
[[1,0,0],
 [0,1,0],
 [0,0,0]]

Output

  • answer = 1

Explanation

Only the bottom right cell is safe

Solution

Leave a comment