Fastest, Python BFS solution
\nclass Solution:\n    def nearestExit(self, grid: List[List[str]], entrance: List[int]) -> int:\n        m=len(grid)\n        n=len(grid[0])\n        lst=[[ent
```\nclass Solution:\n    def nearestExit(self, grid: List[List[str]], entrance: List[int]) -> int:\n        m=len(grid)\n        n=len(grid[0])\n        lst=[[entrance[0],entrance[1],0]]\n        visited=[[-1]*n for i in range(m)]\n        row=[-1,1,0,0]\n        col=[0,0,-1,1]\n        visited[entrance[0]][entrance[1]]=1\n        while lst:\n            x,y,d=lst.pop(0)\n            for i in range(4):\n                if x+row[i]>=0 and x+row[i]<m and y+col[i]>=0 and y+col[i]<n and visited[x+row[i]][y+col[i]]==-1 and grid[x+row[i]][y+col[i]]==\'.\':\n                    if x+row[i]==0 or x+row[i]==m-1 or y+col[i]==0 or y+col[i]==n-1:\n                        return d+1\n                    lst.append([x+row[i],y+col[i],d+1])\n                    visited[x+row[i]][y+col[i]]=1\n        return -1\n```
['Breadth-First Search', 'Graph', 'Python', 'Python3']