Word Ladder

Given two words beginWord and endWord of equal length, and a list of dictionary words wordList, return the number of words in the shortest transformation sequence from beginWord to endWord.

A transformation sequence is a list of words that starts with beginWord, ends with endWord, and where every pair of adjacent words differs in exactly one character. Every word after the first must be present in wordList; beginWord itself does not have to be in the list.

Return 0 when no such sequence exists. When beginWord equals endWord, the sequence contains exactly one word and the answer is 1.

Examples
Input: ["hit","cog",["hot","dot","dog","lot","log","cog"]]
Output: 5
Hints

Word Ladder

Given two words `beginWord` and `endWord` of equal length, and a list of dictionary words `wordList`, return the number of words in the shortest transformation sequence from `beginWord` to `endWord`.