Sub Matrices with sum Zero

Problem Setter: mihai.gheorghe
Problem Tester: sneh_gupta

Given a 2D matrix, find the number non-empty sub matrices, such that the sum of the elements inside the sub matrix is equal to 0. (note: elements might be negative).

Example:

Input

-8 5  7
3  7 -8
5 -8  9

Output
2

Explanation
-8 5 7
3 7 -8
5 -8 9

-8 5 7
3 7 -8
5 -8 9

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Sub Matrices with sum Zero on Interview Code Editor
Sign Up
to access hints and editorial solutions for Sub Matrices with sum Zero
Asked In:
  • Google
Click here to start solving coding interview questions