Word Search

Try to solve the Word Search problem.

Statement

Given an m×nm \times n 2D grid of characters and word as a string, we need to determine if the word can be constructed from letters of sequentially adjacent cells. The cells are considered sequentially adjacent when they are neighbors to each other either horizontally or vertically. The function should return TRUE if the word can be constructed and FALSE otherwise.

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 or uppercase English letters.
  • The search is not case-sensitive.

Examples

Create a free account to view this lesson.

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