[
string
kmp
]
BinarySearch 0037 Unidirectional Word Search
Problem statement
https://binarysearch.com/problems/Unidirectional-Word-Search/
Solution
For each row and column apply string search, using in
function in python.
Complexity
It is O(mn)
for time and O(m + n)
for space.
Code
class Solution:
def solve(self, board, word):
for row in board:
if word in "".join(row): return True
for col in zip(*board):
if word in "".join(col): return True
return False