Hard

Quiz

#212 Word Search II

APPROACH

Given an m x n grid board and a list of strings words, find all words from the list that can be traced on the board.

Each word traces through horizontally or vertically adjacent cells without reusing any cell within the same word.

Example 1:

Input: board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"]
Output: ["eat","oath"]

Example 2:

Input: board = [["a","b"],["c","d"]], words = ["abcb"]
Output: []
1 of 4
1:00

What is the optimal approach for this problem?