C++, BFS, clean code
Code\n\n// BFS\nclass Solution {\npublic:\n    int nearestExit(vector<vector<char>>& maze, vector<int>& entrance) {\n        int m = maze.size(), n = maze[0].si
# Code\n```\n// BFS\nclass Solution {\npublic:\n    int nearestExit(vector<vector<char>>& maze, vector<int>& entrance) {\n        int m = maze.size(), n = maze[0].size();   \n        int DIR[][2] = { {0,-1}, {1,0}, {0,1}, {-1,0} };\n        // r, c, steps\n        queue<array<int, 3>> Q;\n        Q.push({ entrance[0], entrance[1], 0 });\n        maze[entrance[0]][entrance[1]] = \'+\'; // marked as processed\n\n        while (!Q.empty()) {\n            auto [r, c, steps] = Q.front(); Q.pop();\n\n            // If it\'s boundary && it\'s not entrance\n            if ((r == 0 || c == 0 || r == m-1 || c == n-1) && (r != entrance[0] || c != entrance[1]))\n                return steps;\n\n            for (int i = 0; i < 4; i++) {\n                int nr = r + DIR[i][0], nc = c + DIR[i][1];\n                if (nr < 0 || nc < 0 || nr >= m || nc >= n || maze[nr][nc] == \'+\')\n                    continue;\n                maze[nr][nc] = \'+\'; // marked as processed\n                Q.push({ nr, nc, steps+1 });\n            }\n\n        }\n\n        return -1;\n    }\n};\n```
['Array', 'Breadth-First Search', 'Matrix', 'C++']