USING QUEUE (BFS)
\nclass Solution {\npublic:\n    vector<int> rowDir = {-1,1,0,0};\n    vector<int> colDir = {0,0,1,-1};\n    bool border(vector<vector<char>> &maze , int row , 
```\nclass Solution {\npublic:\n    vector<int> rowDir = {-1,1,0,0};\n    vector<int> colDir = {0,0,1,-1};\n    bool border(vector<vector<char>> &maze , int row , int col)\n    {\n        if((row == 0) || (row == maze.size()-1))\n        {\n            return true;\n        }\n        if((col == 0) || (col == maze[0].size()-1))\n        {\n            return true;\n        }\n        return false;\n    }\n    \n    bool validstep(vector<vector<char>> &maze , int &row , int &col)\n    {\n        int m = maze.size();\n        int n = maze[0].size();\n        if(row < 0 || row == m || col < 0 || col == n  || maze[row][col] == \'+\')\n        {\n            return false;\n        }\n        return true;\n    }\n    \n    int nearestExit(vector<vector<char>>& maze, vector<int>& entrance) \n    {\n        queue<pair<int , int>> q; // creating a queue\n        q.push({entrance[0] , entrance[1]}); // initially push the entrance location\n        int path = 0;\n        maze[entrance[0]][entrance[1]] = \'+\'; //mark as visited\n        while(!q.empty()) \n        {\n            int size = q.size();\n            while(size--)\n            {\n                int row = q.front().first;\n                int col = q.front().second;\n                q.pop();\n                for(int direction = 0 ; direction < 4; direction++) // for checking all direction\n                {\n                    int newRow = row + rowDir[direction]; // new row \n                    int newCol = col + colDir[direction];\n                    if(validstep(maze , newRow , newCol))\n                    {\n                        maze[newRow][newCol] = \'+\'; // mark as visited\n                        if(border(maze , newRow , newCol))  // checking is border or not\n                        {\n                            return (path + 1); // if it is border then retuern\n                        }\n                        else\n                        {\n                            q.push({newRow , newCol}); // if not a border then push in queue to next BFS from this\n                        }\n                    }\n                }\n            }\n            path++;\n        }\n        return -1;\n    }\n};\n\n\n```
['C']