Simple java solution
```\nclass Solution {\n    public int nearestExit(char[][] m, int[] e) {\n        int c=0;\n        Queue nm=new LinkedList<>();\n        int a[][]={{0,1},{1,0}
```\nclass Solution {\n    public int nearestExit(char[][] m, int[] e) {\n        int c=0;\n        Queue<int[]> nm=new LinkedList<>();\n        int a[][]={{0,1},{1,0},{-1,0},{0,-1}};\n        nm.offer(e);\n        boolean k[][]=new boolean[m.length][m[0].length];\n        k[e[0]][e[1]]=true;\n        while(!nm.isEmpty())\n        {\n            int p=nm.size();\n            c++;\n            for(int i=0;i<p;i++)\n            {\n                int f[]=nm.poll();\n                for(int b[]:a)\n                {\n                    int x=b[0]+f[0];\n                    int y=f[1]+b[1];\n                    if(x<0||y<0||x>=m.length||y>=m[0].length)\n                        continue;\n                    else if(k[x][y]||m[x][y]==\'+\')\n                        continue;\n                    if(x==0||y==0||x==m.length-1||y==m[0].length-1)\n                        return c;\n                    nm.add(new int[]{x,y});\n                    k[x][y]=true;\n                }\n            }\n        }\n        return -1;\n    }\n}
['Breadth-First Search', 'Java']