Word Search II

Try to solve the Word Search II problem.

Statement

You are given a list of strings that you need to find in a 2D grid of letters such that the string can be constructed from letters in sequentially adjacent cells. The cells are considered sequentially adjacent when they are neighbors to each other either horizontally or vertically. The solution should return a list containing the strings from the input list that were found in the grid.

Constraints:

  • 1≤1 \leq rows, columns ≤12\leq 12
  • 1≤1 \leq words.length ≤3×103\leq 3 \times {10^3}
  • 1≤1 \leq words[i].length ≤10\leq 10
  • grid[i][j] is an uppercase English letter.
  • words[i] consists of uppercase English letters.
  • All the strings are unique.

Note: The order of the strings in the output does not matter.

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