Java DP Solution, short, beats 99%
\npublic static int numberRectangles(int[][] arr){\n        int ans = 0;\n        for (int i = 0; i<arr.length; i++){\n            for (int n = 0; n<arr[0].leng
```\npublic static int numberRectangles(int[][] arr){\n        int ans = 0;\n        for (int i = 0; i<arr.length; i++){\n            for (int n = 0; n<arr[0].length; n++){\n                if (i != 0 && n!= 0 && arr[i][n] != 0){\n                    arr[i][n] += Math.min(arr[i-1][n], Math.min(arr[i][n-1], arr[i-1][n-1])); //A chain is only as strong as it\'s weakest link. Same does for finding squares. \n                }\n                ans += arr[i][n];\n            }\n        }\n        return ans;\n    }\n\t\n```
['Dynamic Programming', 'Java']