Word Ladder I
BFS & DFS Problems DSA practice problem on Onlearn.
Difficulty: hard.
Topics: Shortest Transformation Sequence in Word Ladder Problem, String Manipulation, Breadth-First Search, Graph Traversal, Queue, Hash Tables, Time Complexity, Space Complexity, Brute Force, complexity analysis, hash set, string manipulation, graph traversal, queue, bfs, Graph Traversal Utilities.
Problem Statement: Given two distinct words, startWord and targetWord, and a list wordList of unique words of equal lengths, find the length of the shortest transformation sequence from startWord to targetWord. Conditions for Transformation: A word can only consist of lowercase characters. Only one letter can be changed in each transformation. Each transformed word must exist in the wordList, including the targetWord. startWord may or may not be part of the wordList. Note: If there’s no possible way to transform the sequence from startWord to targetWord, return 0. Input Specification: startWord: A string representing the starting word. targetWord: A string representing the target word. wordList: A list of strings containing unique words of equal length. Output Specification: Return an integer representing the length of the shortest transformation sequence. If no such sequence exists, return 0. Example 1: Example 2: