[golang] prefix sum by row and col
\nfunc largest1BorderedSquare(grid [][]int) int {\n    pl:=make([][]int, len(grid))\n    for i := range pl {\n        pl[i]=make([]int, len(grid[0]))\n        p
```\nfunc largest1BorderedSquare(grid [][]int) int {\n    pl:=make([][]int, len(grid))\n    for i := range pl {\n        pl[i]=make([]int, len(grid[0]))\n        pl[i][0]=grid[i][0]\n        for j := 1; j <len(grid[0]);j++{\n            if grid[i][j]==0{\n                pl[i][j]=0\n                continue\n            }\n            pl[i][j]+=grid[i][j]+pl[i][j-1]\n        }\n    }\n    pc:=make([][]int, len(grid))\n    for i := range pc {\n        pc[i]=make([]int, len(grid[0]))\n        \n    }\n    for j := range pc[0] {\n        pc[0][j]=grid[0][j]\n        for i := 1; i <len(grid);i++ {\n            if grid[i][j]==0 {\n                pc[i][j]=0\n                continue\n            }\n            pc[i][j]+=grid[i][j]+pc[i-1][j]\n        }\n    }    \n    r:=0\n    for i := 0;i < len(grid);i++{\n        for j := 0;j < len(grid[0]);j++{\n            m:=min(pc[i][j],pl[i][j])\n            for sz:=1;sz<=m;sz++{\n                d:=sz-1\n                if i-d<0 || j-d<0{continue}\n                rsz:=min(pl[i-d][j],pc[i][j-d])\n                if rsz>=sz{ r=max(r,sz*sz) }\n            }\n        }\n    }\n    return r\n}\nfunc min(x, y int) int {\n\tif x < y { return x }\n\treturn y\n}\nfunc max(x, y int) int {\n\tif x > y { return x }\n\treturn y\n}\n```
[]