Amazon Interview Question

Leetcode hard question: ladder word