RAM RAM SARAEYA NU
class Solution {\n    public:\n        int largest1BorderedSquare(vector>& grid) \n        {\n            int n=grid.size();\n            int m=grid[0].size();\
class Solution {\n    public:\n        int largest1BorderedSquare(vector<vector<int>>& grid) \n        {\n            int n=grid.size();\n            int m=grid[0].size();\n            vector<vector<pair<int,int>>> dp(n+1,vector<pair<int,int>> (m+1));\n\n            for(int i=n-1;i>=0;i--)\n            {\n                for(int j=m-1;j>=0;j--)\n                {\n                    if(grid[i][j]==0)\n                        continue;\n                    dp[i][j].first=dp[i][j+1].first+1;\n                    dp[i][j].second=dp[i+1][j].second+1;\n                }\n            }    \n\n            int ans=0;\n\n            for(int i=0;i<n;i++)\n            {\n                for(int j=0;j<m;j++)\n                {\n                    int e=min(dp[i][j].first,dp[i][j].second);\n                    int k=e;\n                    for(k=e;k>0;k--)\n                    {\n                        if(dp[i][j+k-1].second>=k && dp[i+k-1][j].first>=k)\n                            break;\n                    }\n                    ans=max(ans,k);\n                }\n            }\n\n            return ans*ans;\n        }\n    };\n
['C++']