← 返回 google 的题目列表Form Word in Given Steps
类型:online_judge
Given a keyboard matrix composed of characters, a word, and a step count, determine if the word can be formed in the given steps using BFS. The function should output a boolean. Characters in the matrix can move up, down, left, and right. The test cases should consider various edge cases.
Example Input
3 3
abc
def
ghi
word
6
Example Output
True
Constraints
The matrix size ranges from 1x1 to 10x10
The word length does not exceed the total number of characters in the matrix
Example
Input
3 3
abc
def
ghi
word
6