Search⌘ K
AI Features

Word Ladder II

Explore how to apply backtracking techniques to find all shortest transformation sequences between two words. Understand constraints like single letter changes, and learn to return all valid paths efficiently. This lesson equips you with a practical approach to solve word ladder problems in coding interviews.

Statement

You are given two words, beginWord and endWord, and a dictionary of words called wordList. Your task is to find all the shortest transformation sequences from beginWord to endWord, such that:

  1. Only one letter can be changed at a time.

  2. Each transformed word must exist in the given wordList.

  3. The transformation sequence must begin with beginWord and end with endWord.

Return all the shortest transformation sequences as a list of lists. If no valid transformation exists, return an empty list.

Constraints:

  • ...