Understand the problem
Restate the problem precisely. Interviewers reward candidates who pause, define the contract, and name the guarantees before coding.
A transformation sequence from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s₁ -> s₂ -> ... -> sₖ` such that every adjacent pair of words differs by a single letter, every `sᵢ` for `1 ≤ i ≤ k` is in `wordList` (note that `beginWord` does not need to be in `wordList`), and `sₖ == endWord`. Given two words, `beginWord` and `endWord`, and a dictionary `wordList`, return the number of words in the shortest transformation sequence from `beginWord` to `endWord`, or `0` if no such sequence exists.
Once you've drafted a response, click Submit for AI review and a senior engineer will critique your reasoning.