Advertisement
jbjares

Untitled

Aug 18th, 2015
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that only one letter can be changed at a time and each intermediate word must exist in the dictionary. For example, given:
  2.  
  3. start = "hit"
  4. end = "cog"
  5. dict = ["hot","dot","dog","lot","log"]
  6. One shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", the program should return its length 5.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement