Google interview question

It was a leetcode medium question, word pattern matching on keyboard.