Simple java| 11 lines of code| easy understanding
\nclass Solution {\n    public int countSquares(int[][] matrix) {\n    int count = 0;\n    for(int i = 0; i < matrix.length; i++) \n      for(int j = 0; j < mat
```\nclass Solution {\n    public int countSquares(int[][] matrix) {\n    int count = 0;\n    for(int i = 0; i < matrix.length; i++) \n      for(int j = 0; j < matrix[0].length; j++){ \n        //Nothing need to be done on 0th column and row ;\n          if(matrix[i][j] > 0 && i > 0 && j > 0) \n          matrix[i][j] = Math.min(matrix[i-1][j], Math.min(matrix[i][j-1], matrix[i-1][j-1]))+1;\n          count += matrix[i][j];\n      }  \n    return count;       \n    }\n}\n```
['Dynamic Programming', 'Java']