Code Room
CodingHardcod-g017
Subject BfsLevel Senior–Staff~40 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a start word, an end word, and a word list, return the length of the shortest transformation sequence from start to end, where each step changes exactly one letter and every intermediate word (including the end) must be in the word list. The start word need not be in the list. All words have the same length and contain lowercase letters only. Return 0 if no such sequence exists. The sequence length counts the number of words in it (start and end inclusive).

Implement
word_ladder_length(start: 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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.