Amazon interview question

Word Ladder from leetcode directly