Problem Description
Given two words A and B, and a dictionary C, find the length of shortest transformation sequence from A to B, such that:
NOTE:
The first argument of input contains a string, A.
The second argument of input contains a string, B.
The third argument of input contains an array of strings, C.
Return an integer representing the minimum number of steps required to change string A to string B.
Input 1:
A = "hit" B = "cog" C = ["hot", "dot", "dog", "lot", "log"]
Input 2:
A = "cat" B = "bat" C = ["rat"]
Input 3:
A = "bait" B = "pant" C = ["a","b"]
Output 1:
5
Output 2:
2
Output 3:
0
Explanation 1:
"hit" -> "hot" -> "dot" -> "dog" -> "cog"
Explanation 2:
"cat" -> "bat"
Explanation 3:
No intermediate words are present in the given dictionary so transformation is not possible. We will return 0 for this case.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.