Java Solution Using BFS
\n\nclass Pair\n{\n    int row;\n    int col;\n    int steps;\n    Pair(int _row , int _col , int _steps)\n    {\n        this.row = _row;\n        this.col = _
\n```\nclass Pair\n{\n    int row;\n    int col;\n    int steps;\n    Pair(int _row , int _col , int _steps)\n    {\n        this.row = _row;\n        this.col = _col;\n        this.steps = _steps;\n    }\n}\n\nclass Solution \n{\n    public int nearestExit(char[][] maze, int[] entrance) \n    {\n        Queue<Pair> q = new LinkedList<>();\n        q.add(new Pair(entrance[0] , entrance[1] , 0));\n        int m = maze.length;\n        int n = maze[0].length;\n        int visited[][] = new int[m][n];\n        \n        for(int i=0;i<m;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                if(maze[i][j] == \'+\')\n                    visited[i][j] = 1;\n                else\n                    visited[i][j] = 0;\n            }\n        }\n        \n        int arow[] = {1,0,-1,0};\n        int acol[] = {0,-1,0,1};\n        int ans = -1;\n        boolean flag = false;\n        \n        while(!q.isEmpty())\n        {\n            int row = q.peek().row;\n            int col = q.peek().col;\n            int steps = q.peek().steps;\n            q.remove();\n            visited[row][col] = 1;\n            for(int i=0;i<4;i++)\n            {\n                int nrow = row + arow[i];\n                int ncol = col + acol[i];\n                if(nrow>=0 && nrow<m && ncol>=0 && ncol<n && visited[nrow][ncol] != 1)\n                {\n                    visited[nrow][ncol] = 1;\n                    q.add(new Pair(nrow,ncol,steps+1));\n                    if(ncol==0 || nrow==0 || nrow==m-1 || ncol==n-1)  \n                    {\n                        flag = true;\n                        ans = steps+1;\n                        break;\n                    }\n                }\n            }\n            \n            if(flag == true)\n                break;\n        }\n        \n        return ans;\n        \n    }\n}\n```
['Breadth-First Search', 'Java']