Amazon interview question

Leetcode hard question: ladder word