Word Ladder II
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that every adjacent pair differs by a single letter, every si is in wordList, and sk == endWord. Given two words and a dictionary, return all the shortest transformation sequences.

30:00

Word Ladder II
hard
Topics
Companies

A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that every adjacent pair differs by a single letter, every si is in wordList, and sk == endWord. Given two words and a dictionary, return all the shortest transformation sequences.

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

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

  • 1wordList.length5001 \leq \text{wordList.length} \leq 500

  • 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 from "hit" to "cog"

Start

hit

Target

cog

Level 1 - Exploring
hit
Word Dictionary
hot
dot
dog
lot
log
cog
Level: 1
Visited: 1
Paths: 0
Variables
No variables to display
DepthFunction Call
Stack empty
0/6