Given a finite set of three letter words How will you find out minimum number of hops required to reach from one word to the other.
Conditions :
Hops should be minimum.
Resulting word should be in the set.
Ex
Input [‘sat’,’cat’,’rat’,’tap,’stt’]
‘sat’
‘stt’
Output 1