Simple C++ || BFS || Straight-Forward Solution ||
\nclass Solution {\npublic:\n        int dir[5]={0,1,0,-1,0};\n    int nearestExit(vector<vector<char>>& maze, vector<int>& e) {\n        vector<vector<bool>>vi
```\nclass Solution {\npublic:\n        int dir[5]={0,1,0,-1,0};\n    int nearestExit(vector<vector<char>>& maze, vector<int>& e) {\n        vector<vector<bool>>vis(maze.size(),vector<bool>(maze[0].size(),0));\n        queue<vector<int>>q;\n        q.push({e[0],e[1],0});\n        vis[e[0]][e[1]]=1;\n        while(!q.empty()){\n            vector<int>p=q.front();q.pop();\n            for(int i =0;i<4;i++){\n                int x=p[0]+dir[i],y=p[1]+dir[i+1];\n\n                    if(x<0 || y<0 || x>=maze.size() ||  y>=maze[0].size() || maze[x][y]==\'+\')continue;\n                    if((x==0 || y==0 || x==(maze.size()-1) ||  y==(maze[0].size()-1)) && maze[x][y]!=\'+\' && !vis[x][y])return p[2]+1;\n\t\t\t\t\t// To avoid TLE mark the cell {x,y} as Visited\n                    if( maze[x][y]!=\'+\' && !vis[x][y])vis[x][y]=1,q.push({x,y,p[2]+1});\n            }\n            \n        }\n        return -1;\n    }\n};\n\n```
['Breadth-First Search', 'C']