Medium · Matrices
Check if Word Can Be Placed In Crossword
Given an m × n crossword board whose cells are ' ' (empty), '#' (blocked) or a lowercase letter, and a lowercase word, return true if the word can be written left-to-right, right-to-left, top-to-bottom or bottom-to-top so that no letter lands on '#', every letter lands on an empty cell or the same letter, and the cells directly before and after the word are '#' or off the board; otherwise return false.
Examples
Example 1
{
"board": ["# ", " c", " #"],
"word": "abc"
}Output: true (placeable)
Example 2
{
"board": ["# #", " ", "# #"],
"word": "ac"
}Output: false (no fit)
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.