Java Solution 4 ms, faster than 99.10% using backtracking
PLEASE UPVOTE THIS SOLUTION IF YOU LIKE THIS \u270C\uFE0F\n\nIntiuition:  \n- To search a word in grid, we can start from a index (x, y) and then try every dire
**PLEASE UPVOTE THIS SOLUTION IF YOU LIKE THIS** \u270C\uFE0F\n\nIntiuition:  \n- To search a word in grid, we can start from a index (x, y) and then try every direction using dfs.\n- If word char is match with the cell than Increment the wordIndex and try that cell neighbour.\n- if word doesn\'t match then replace the char with original cell char\n\n\n```\nclass Solution {\n    public boolean exist(char[][] board, String word) {\n        \n        for(int x = 0; x < board.length; x++){\n\t\t    for(int y = 0; y < board[0].length; y++){\n\t\t\t\t//start from every cell, \n\t\t\t\t//if any of found the word in the grid, return true\n                if(exist(board, x, y, word, 0)) return true;\n            }\n        }\n        \n\t\t//if not found\n        return false;\n    }\n    \n    public boolean exist(char[][] board, int x, int y, String word, int wordIndex){\n\n        if(wordIndex == word.length()) return true;\n        \n\t\t//check boundary of grid\n        if( x < 0 || x >= board.length ||  y < 0 ||  y >= board[0].length) return false;\n\t\t\n\t\tchar currCellChar =  board[x][y];\n\t\t\n\t\t//check currently, this cell is being used for dfs\n\t\tif(currCellChar == \'$\') return false;\n\t\t \n\t\t //check cell char is equal to  current char of word\n\t\tif(currCellChar != word.charAt(wordIndex)) return false;\n        \n\t\t//mark this cell as used\n        board[x][y] = \'$\';\n        \n        boolean isExist = exist(board, x + 1, y, word, wordIndex + 1) ||    // direction UP \n\t\t\t\t\t\t\t\t\t  exist(board, x - 1, y, word, wordIndex + 1) ||    // direction DOWN\n\t\t\t\t\t\t\t\t\t  exist(board, x, y + 1, word, wordIndex + 1) ||   // direction RIGHT\n\t\t\t\t\t\t\t\t\t  exist(board, x, y - 1, word, wordIndex + 1);     // direction LEFT\n            \n\t\t//for the backtracking, try different possibilty,  now unmark this cell as free, \t\n        board[x][y] = currCellChar;\n        \n        return isExist;\n    }\n    \n}\n```
['Backtracking', 'Java']