Python3 || Beats 100% || Easy Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def largest1BorderedSquare(self, grid: List[List[int]]) -> int:\n        maxi = 0\n        rows = len(grid)\n        cols = len(grid[0])\n\n        hor = [[0]*cols for _ in range(rows)]\n        ver = [[0]*cols for _ in range(rows)]\n\n        # Auxilliary Horizontal and Vertical DP\n\n        for i in range(rows):\n            for j in range(cols):\n\n                if grid[i][j] == 1:\n                    if j == 0:\n                        hor[i][j] = hor[i][j] = 1\n                    else:\n                        hor[i][j] = hor[i][j-1] + 1\n                    \n                    if i == 0:\n                        ver[i][j] = 1\n                    else:\n                        ver[i][j] = ver[i-1][j] + 1\n                    \n        # for i in range(rows):\n        #     for j in range(cols):\n        #         print(hor[i][j],sep=\' \',end=\'\')\n        #     print() \n        \n        # print()\n\n        # for i in range(rows):\n        #     for j in range(cols):\n        #         print(ver[i][j],sep=\' \',end=\'\')\n        #     print()\n\n\n        for i in range(rows-1,-1,-1):\n            for j in range(cols-1,-1,-1):\n                small = min(ver[i][j], hor[i][j])\n\n                while(small > maxi):\n                    if ver[i][j - small + 1] >= small and hor[i - small + 1][j] >= small:\n                        maxi = small\n                    # If above conition is not true then decrement small\n                    small-=1\n\n        return (maxi*maxi)\n                    \n```
['Python3']