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

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.