# Leetcode 79 - Word search

Note:

• Update:
• Use only DFS is not enough, because from one point, we can go multiple ways,
what if one way is not correct, but the other is correct? We must return from the wrong way, and redirect to the correct way. Hence backtracking.
• This is a DFS + backtracking problem.
• Intialize path with path[word[0]].
• Call dfs() from board[i][j] = word[0].
• Use used[][] to mark elements that have been visited.
• Use directional array to get 4 directions.

Question:

Given an m x n grid of characters board and a string word, return true if word exists in the grid.

The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.

Example:

Code: