Skip to content

79. Word Search #55

Answered by mah-shamim
mah-shamim asked this question in Q&A
Jul 17, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

To solve this problem, we can follow these steps:

Let's implement this solution in PHP: 79. Word Search

Explanation:

  1. Initialization:

    • The exist function iterates through each cell in the grid. It starts a DFS search from each cell to see if the word can be constructed from that starting point.
  2. DFS Search (dfs function):

    • Bounds Check: The DFS function first checks if the current position is out of bounds or if the character at the current position doesn't match the current character in the word.
    • Word Completion: If the current character matches and the end of the word is reached, it returns true.
    • Marking Cells: It marks the current cell as visited by setting it to '*' to avoid reusin…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@basharul-siddike
Comment options

@mah-shamim
Comment options

mah-shamim Jan 23, 2025
Maintainer Author

Answer selected by basharul-siddike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants