Pregunta de entrevista de Two Sigma

I got asked Word Search II leetcode question