← 返回 bloomberg 的题目列表Word Search in a 2D board
类型:online_judge
Problem
Given an m x n grid of characters board and a string word, determine whether word can be formed by sequentially adjacent cells.
Adjacent means up/down/left/right
The same cell may not be used more than once in a single path
Output true/false.
Constraints
1 <= m, n <= 20
1 <= len(word) <= m*n
Example
Input:
3 4
A B C E
S F C S
A D E E
ABCCED
Output:
true
Example
Input
3 4
A B C E
S F C S
A D E E
ABCCED
Output
true