Word Search

Try to solve the Word Search problem.

Statement

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 formed by connecting letters of sequentially adjacent cells. The cells are considered sequentially adjacent when neighbors are either horizontally or vertically neighbors. Each cell can be used only once while forming the word.

Constraints:

  • m ==== board.length

  • n == board[i].length, where 0≤0 \leq i << m

  • 1≤1 \leq m, n ≤6\leq 6

  • 1≤1 \leq word.length ≤15\leq 15

  • board and word consist of only lowercase and uppercase English letters.

Examples

Create a free account to view this lesson.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy