Amazon Interview Question

Variation of this LC https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/