> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/algorithms-problem-solving-skills/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/algorithms-problem-solving-skills/graph-dfs-bfs/word-ladder.md).

# Word Ladder

Given two words `beginWord` and `endWord`, and a dictionary `wordList`, return *the length of the shortest transformation sequence from* `beginWord` *to* `endWord`, *such that*:

* Only one letter can be changed at a time.
* Each transformed word must exist in the word list.

Return `0` if there is no such transformation sequence.

![](https://3269900549-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIbwNq54Ge4eqsziHM7%2F-MPqZwudUKxZkD7LHfBL%2F-MPq_9-NWL8-G1zo0lZD%2FScreen%20Shot%202020-12-31%20at%2011.15.43%20AM.png?alt=media\&token=8613db9c-6019-47b9-b1fb-0f25dadf6adc)
