title: How do you find the number of rectangles in a 2D matrix of 0s and 1s?
body: <p>I have searched a number of posts here on SO as well as other resources online. Most of them provide a solution for finding the maximum area of a rectangle in a 2D matrix, which I understand. However, I am curious to know the way you find the number of rectangles in a 2D matrix where a rectangle is <strong>represented by 1s</strong>.</p>
  
  <p><strong>Update:</strong>
  Apologize for not clarifying the scenario as to what classifies as a rectangle - it is considered a rectangle if the cells inside a certain perimeter are <strong>filled</strong> with 1s. </p>