Number of submatricies containing all zeros
问题 Is there a way to find a number of rectangular submatrices containing all zeros with a complexity smaller than O(n^3), where n is the dimension of given matrix? 回答1: Here is a solution O(n² log n) . First, let's convert the main problem to something like this: For given histogram, find the number of submatrices containing all zeros. How to convert it ? For each position calculate the height of column that start on that position and contain only zeros. Example: 10010 01101 00111 12000 00001 ->