Easy BFS Solution With Comments and approach
INTUITION: From the entrance start a bfs for all the four directions  and stop if you reach any border cells and they are not walls.\n\nclass Solution {\npublic
INTUITION: From the entrance start a bfs for all the four directions  and stop if you reach any border cells and they are not walls.\n```\nclass Solution {\npublic:\n    int dx[4]={0,0,-1,1}; \n    int dy[4]={1,-1,0,0};\n    int nearestExit(vector<vector<char>>& maze, vector<int>& entrance) {\n        int n=maze.size();\n        int m=maze[0].size();\n        vector<vector<bool>> vis(n,vector<bool>(m,false)); // vis array to keep track of visited cells\n        queue<pair<int,int>> q;  // Initialising a queue to store indexes\n        q.push({entrance[0],entrance[1]});\n        vis[entrance[0]][entrance[1]]=true;\n        int count=0; \n        while(q.empty()==false)\n        {\n            int sz=q.size();\n            count++;\n            while(sz--)\n            {\n                int x=q.front().first;\n                int y=q.front().second;\n                q.pop();\n                for(int idx=0;idx<4;idx++)\n                {\n                    int nx=x+dx[idx];\n                    int ny=y+dy[idx];\n\t\t\t\t\t// checking if the cell we are traversing to is valid or not such as whether it is within boundary and not a wall\n                    if(nx>=0 && nx<n && ny>=0 && ny<m && vis[nx][ny]==false && maze[nx][ny]!=\'+\') \n                    {\n                        if(nx==0 || nx==n-1 || ny==0 || ny==m-1) // checking if it is a boundary cell an if true we return the count.\n                            return count;\n                        q.push({nx,ny});\n                        vis[nx][ny]=true;\n                    }   \n                }\n                \n            }\n        }\n        return -1; // if there is no way out return -1\n    }\n};\n```
['Breadth-First Search', 'Queue', 'C', 'C++']