Google | Onsite | Number of Submatrices With Sum Zero
Anonymous User
1377

Given a matrix full of 0s and 1s, find the number of sub groups of zeroes.
Edit: You can also consider as number of rectangles formed by 0s.

[0,0,1,0,0] 
"""
# subgroups = 6 

pattern : count

0 : 4

00 : 2
"""
 
[ 
0,0,1,0,0
0,1,0,0,0
] 
"""
# subgroups = 17

pattern : count

0 : 8

00 : 4

000 : 1

0
0 : 3

00
00:1
"""

I tried using number of substrings formula, n*(n+1)/2. That is true only for 1 dimensional list.
There has to be some variation for the above. Any idea?

Related problems:

Comments (8)