Amazon interview question

solve boogle using a function