My Java solution
public class Solution {\n        static boolean[][] visited;\n        public boolean exist(char[][] board, String word) {\n            visited = new boolean[boa
    public class Solution {\n        static boolean[][] visited;\n        public boolean exist(char[][] board, String word) {\n            visited = new boolean[board.length][board[0].length];\n            \n            for(int i = 0; i < board.length; i++){\n                for(int j = 0; j < board[i].length; j++){\n                    if((word.charAt(0) == board[i][j]) && search(board, word, i, j, 0)){\n                        return true;\n                    }\n                }\n            }\n            \n            return false;\n        }\n        \n        private boolean search(char[][]board, String word, int i, int j, int index){\n            if(index == word.length()){\n                return true;\n            }\n            \n            if(i >= board.length || i < 0 || j >= board[i].length || j < 0 || board[i][j] != word.charAt(index) || visited[i][j]){\n                return false;\n            }\n            \n            visited[i][j] = true;\n            if(search(board, word, i-1, j, index+1) || \n               search(board, word, i+1, j, index+1) ||\n               search(board, word, i, j-1, index+1) || \n               search(board, word, i, j+1, index+1)){\n                return true;\n            }\n            \n            visited[i][j] = false;\n            return false;\n        }\n    }
['Java']