Word Ladder
Given two words beginWord and endWord, and a dictionary wordList, return the number of words in the shortest transformation sequence from beginWord to endWord (changing one letter at a time).

30:00

Word Ladder
hard
Topics
Companies

Given two words beginWord and endWord, and a dictionary wordList, return the number of words in the shortest transformation sequence from beginWord to endWord (changing one letter at a time).

Example 1:
Input: {"beginWord":"hit","endWord":"cog","wordList":["hot","dot","dog","lot","log","cog"]}
Output: 5
Constraints:
  • 1beginWord.length101 \leq \text{beginWord.length} \leq 10

  • endWord.length==beginWord.length\text{endWord.length} == \text{beginWord.length}

  • 1wordList.length50001 \leq \text{wordList.length} \leq 5000

  • wordList[i].length==beginWord.length\text{wordList}[i].\text{length} == \text{beginWord.length}

  • beginWord, endWord, and wordList[i] consist of lowercase English letters.

  • All wordList[i] are unique.

Input
arr ={"beginWord":"hit","endWord":"cog","wordList":["hot","dot","dog","lot","log","cog"]}

Start BFS

Start

hit

Target

cog

Processing (Level 1)

hit

Word Dictionary
hot
dot
dog
lot
log
cog
BFS Queue

hit (L1)

Level: 1
Visited: 1
Queue: 1
Current
Visited
Target
Variables
No variables to display
DepthFunction Call
Stack empty
0/6