Thought Machine interview question

LeetCode 139: Word Break (medium)