Easy to under simple java solution
Intuition\nReferred other solutions, and made changes easier for me to understand. \n\n# Approach\nStore left to right sum array and top to bottom sum array. Ev
# Intuition\nReferred other solutions, and made changes easier for me to understand. \n\n# Approach\nStore left to right sum array and top to bottom sum array. Every point in this array is considered bottom right point of a square and check if top right and bottom left corners of square satisfy the required condition of minimum number of 1s.\n\n# Complexity\n- Time complexity: Worst case O(N^3)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N^2)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int largest1BorderedSquare(int[][] grid) {\n        int m = grid.length, n = grid[0].length;\n        int[][] left = new int[m][n];\n        int[][] top = new int[m][n];\n        for (int i = 0; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                if (grid[i][j] == 1) {\n                    left[i][j] = j > 0 ? left[i][j-1] + 1 : 1;\n                    top[i][j] = i > 0 ? top[i-1][j] + 1 : 1;\n                }\n            }\n        }\n        int res = 0;\n        for (int i = 0; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                int limit = Math.min(left[i][j], top[i][j]); // Maximum possible square from this bottom right point\n                for (int k = limit; k > 0; k--) {\n                    if (left[i-k+1][j] >= k && top[i][j-k+1] >= k) { // Check if corresponding bottom left and top right points satisfy required number of 1s\n                        res = Math.max(res, k * k);\n                        break;\n                    }\n                }\n            }\n        }\n        return res;\n    }\n}\n```
['Java']