SIMPLE CODE | DP | O(N^2) TIME SPACE | PYTHON
Naive Approach will go to every index, run while loop to top,bottom,left,right and find count of one for each. Minimum of those count gives largest size of + fo
Naive Approach will go to every index, run while loop to top,bottom,left,right and find count of one for each. Minimum of those count gives largest size of + for that index. Then , we need to maximize the answer. \n\nRead the comments above each for loop to know its functionality. This is Dp approach that runs in O(N^2) Time complexity and O(N^2) Space complexity.\n\n```\nclass Solution:\n    def orderOfLargestPlusSign(self, n: int, mines: List[List[int]]) -> int:\n        \n        #creating matrix\n        mine=[[1]*n for i in range(n)]\n        for i in mines:\n            mine[i[0]][i[1]]=0\n        mines=mine\n        \n        x=[[[0,0,0,0] for k in range(n)] for i in range(n)]\n        #top,bottom,left,right\n        \n        # initializing top and left of (0,0)th element\n        if(mines[0][0]==1):\n            x[0][0]=[1,0,1,0]\n            \n        answer=0\n        \n        # initializing top and left of 1st row elements\n        for i in range(1,n):\n            if(mines[0][i]==1):\n                x[0][i][2]=x[0][i-1][2]+1\n                x[0][i][0]=1\n                answer=1\n        \n        # initializing top and left of 1st column elements\n        for i in range(1,n):\n            if(mines[i][0]==1):\n                x[i][0][0]=x[i-1][0][0]+1\n                x[i][0][2]=1\n                answer=1\n               \n        # initializing bottom and right of (-1,-1)th element\n        # increment instead of [0,1,0,1] coz it may fail for matrix size n=1\n        if(mines[-1][-1]==1):\n            x[-1][-1][1]+=1\n            x[-1][-1][3]+=1\n            answer=1\n            \n        # initializing bottom and right of last row elements\n        for i in range(n-2,-1,-1):\n            if(mines[-1][i]==1):\n                x[-1][i][3]=x[-1][i+1][3]+1\n                x[-1][i][1]=1\n                answer=1\n              \n        # initializing bottom and right of last column elements\n        for i in range(n-2,-1,-1):\n            if(mines[i][-1]==1):\n                x[i][-1][1]=x[i+1][-1][1]+1\n                x[i][-1][3]=1\n                answer=1\n                \n        # updating top and left of last n-1 row elements in top-down approach\n        for i in range(1,n):\n            for j in range(1,n):\n                if(mines[i][j]==1):\n                    x[i][j][0]=x[i-1][j][0]+1\n                    answer=1\n                if(mines[i][j]==1):\n                    x[i][j][2]=x[i][j-1][2]+1\n                    answer=1\n        \n        # updating bottom and right of first n-1 row elements in bottom up approach\n        for i in range(n-2,-1,-1):\n            for j in range(n-2,-1,-1):\n                if(mines[i][j]==1):\n                    x[i][j][1]=x[i+1][j][1]+1\n                if(mines[i][j]==1):\n                    x[i][j][3]=x[i][j+1][3]+1\n                answer=max(answer,min(x[i][j]))\n            \n        return answer\n```
[]