Code RoomWord transformation sequence
MediumPrep Room Coding #1063

Word transformation sequence

CodingAlgorithms & data structuresMid–Senior~30 min

Given a begin word, an end word, and a dictionary of equal-length lowercase words, you may transform one word into another by changing exactly one letter at a time, and every intermediate word must be in the dictionary. Return the number of words in the shortest transformation sequence from begin to end, inclusive of both endpoints. The begin word need not be in the dictionary, but the end word must be. Return 0 if no transformation is possible. All words have length 1..10 and the dictionary has at most 5000 words.

Implement
ladder_length(begin: str, end: str, words: list[str]) → int
Examples
in["hit","cog",["hot","dot","dog","lot","log","cog"]]out5
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 30 min
InputExpectedGot
["hit","cog",["hot","dot","dog","lot","log","cog"]]5not run yetsample