Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Word Ladder

Hard Graphs

Given beginWord, endWord and a dictionary, print the number of words in the shortest sequence from beginWord to endWord where each step changes exactly one letter and each intermediate word is in the dictionary. Print 0 if no sequence exists.

Constraints

1 <= len(word) <= 10 1 <= d <= 5000

Discussion

No discussions yet.

Rewards · v2.1

Join Shalyam Newsletter

Get exclusive insights with every issue: education, research and innovation news.

One email a week. Unsubscribe any time.