I was doing the problem : http://oj.leetcode.com/problems/word-ladder/, in which I applied BFS type approach on an undirected graph.. For the given test case (attached below) I think we can achieve the transformation in a single step, by going from "a" - > "c" , wherein both the said words exist in the dictionary , and the resulting transformation requires minimum steps. Why is the answer then 2?
Input: "a", "c", ["a","b","c"]
Yes, it might a little bit confused.
But you can assume that the answer is always more than 2, except 0, which means there is no available transformation. Since no matter the transformation is, start word and end word will be in it.
For this test case, the transformation path would be
'a'->'b', length is 2. If some transformation is like
'a'->'b'->'c', the answer would be 3.