C++ || BFS || Easy to Understand
\nclass Solution {\npublic:\n    vector<int>rowDir = {-1, 1, 0, 0};\n    vector<int>colDir = {0, 0, -1, 1};\n    bool isAtBorder(vector<vector<char>>&maze, int 
```\nclass Solution {\npublic:\n    vector<int>rowDir = {-1, 1, 0, 0};\n    vector<int>colDir = {0, 0, -1, 1};\n    bool isAtBorder(vector<vector<char>>&maze, int row, int col)\n    {\n        if ((row == 0) || (row == maze.size() - 1)) return true;\n        if ((col == 0) || (col == maze[0].size() - 1)) return true;\n        return false;\n    }\n    bool isValidStep(vector<vector<char>>&maze, int& row, int& col)\n    {\n        int m = maze.size(), n = maze[0].size();\n        if (row < 0 || row == m || col < 0 || col == n || maze[row][col] == \'+\') return false;\n        else return true;\n    }\n    int nearestExit(vector<vector<char>>& maze, vector<int>& entrance) \n    {\n        queue<pair<int, int>>q;\n        q.push({entrance[0], entrance[1]});\n        int pathLen = 0;\n        maze[entrance[0]][entrance[1]] = \'+\'; //Instead of using a visited matrix, just mark the visited cell as \'+\'\n                                       //\'+\' will mean that it is either a wall or cell that is  already visited\n        while(!q.empty())\n        {\n            int size = q.size();\n            while(size--)\n            {\n                int currRow = q.front().first;\n                int currCol = q.front().second;\n                q.pop();\n\n                //================================================================================\n                //explores all adjacent cells without writing more code \n                for (int dirIdx = 0; dirIdx < 4; dirIdx++) //checking top, bottom, left, right\n                {\n                    int newRow = currRow + rowDir[dirIdx];  //currRow - 1, currRow + 1, currRow + 0, currRow + 0\n                    int newCol = currCol + colDir[dirIdx];  //currCol + 0, currCol + 0, currCol - 1, currCol + 1\n                    if (isValidStep(maze, newRow, newCol)) \n                    {\n                        maze[newRow][newCol] = \'+\'; //mark as visited and push in queue\n                        if (isAtBorder(maze, newRow, newCol)) return (pathLen + 1); //BOOM, GOT YOUR TARGET :))\n                        else q.push({newRow, newCol});\n                    }\n                }\n                //====================================================================================\n            }\n            pathLen++; \n        }\n        return -1;\n    }\n};\n```
['Breadth-First Search', 'Queue', 'C', 'C++']