Question bankPricingSign in

Word Transformation Chain

GraphsHard1:30

Given a start word, an end word, and a dictionary of valid words, find the length of the shortest transformation sequence from start to end. Each step changes exactly one letter, and every intermediate word must exist in the dictionary.

For example: start = "hit", end = "cog", dictionary = ["hot","dot","dog","lot","log","cog"]. The shortest chain is "hit" -> "hot" -> "dot" -> "dog" -> "cog" (length 5).

Explain your approach, including why you chose it, and analyze complexity.

How to approach it

  • Hint 1

    Think of each word as a node in a graph. When are two nodes connected?

  • Hint 2

    What graph traversal finds the shortest path in an unweighted graph?

  • Hint 3

    Consider using wildcard patterns (e.g., 'h*t') to efficiently find neighbors.

Ready to answer it out loud?

Record your answer in 1:30 and Preptile scores it 1–10 with specifics — what landed, what you skipped, and what to say next time.

Practising needs an invite code. Join the waitlist and we’ll send you one.