Advertisement
jbjares

Untitled

Aug 17th, 2015
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that:
  2.  
  3. Only one letter can be changed at a time
  4. Each intermediate word must exist in the dictionary
  5. For example,
  6.  
  7. Given:
  8. start = "hit"
  9. end = "cog"
  10. dict = ["hot","dot","dog","lot","log"]
  11. As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog",
  12. return its length 5.
  13.  
  14. Note:
  15. Return 0 if there is no such transformation sequence.
  16. All words have the same length.
  17. All words contain only lowercase alphabetic characters.
  18.  
  19.  
  20. =============================================================================================================
  21. Initial code:
  22.  
  23.  
  24. public class Solution {
  25.     public int ladderLength(String beginWord, String endWord, Set<String> wordDict) {
  26.        
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement