JAVA DFS Simple solution
If you found the solution helpful, kindly upvote or like. :)\n\n\nclass Solution {\n    boolean visited[][];\n    public boolean exist(char[][] board, String wo
If you found the solution helpful, kindly upvote or like. :)\n\n```\nclass Solution {\n    boolean visited[][];\n    public boolean exist(char[][] board, String word) {\n        \tvisited= new boolean[board.length][board[0].length];\n\t\tfor(int i=0; i<board.length; i++)\n\t\t\tfor(int j=0; j<board[0].length; j++)\n\t\t\t\tif(board[i][j]==word.charAt(0) && search(i,j,0,board,word))\n\t\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\tprivate boolean search(int i, int j, int index, char[][] board, String word) {\n\t\tif(index==word.length())\n\t\t\treturn true;\n\t\tif(i>=board.length|| i<0 || j<0 || j>= board[0].length \n\t\t\t\t|| visited[i][j] || word.charAt(index)!=board[i][j])\n\t\t\treturn false;\n\t\t\n\t\tvisited[i][j]=true;\n\t\tif(search(i+1, j, index+1, board, word)||\n\t\t\tsearch(i-1, j, index+1, board, word)||\n\t\t\tsearch(i, j+1, index+1, board, word)||\n\t\t\tsearch(i, j-1, index+1, board, word))\n\t\t\treturn true;\n\t\t\n\t\tvisited[i][j]=false;\n\t\treturn false;\n    }\n}\n```
[]