Recently I had an interview and I was asked to write a algorithm to find the minimum number of 1 letter changes to get from a particular of word to a given word , i.e. Cat->Cot->Cog->Dog
I dont want the solution of the problem just guide me through How I can use BFS in this algorithm ?
according to this scrabble list, the shortest path between cat and dog is:
[‘CAT’, ‘COT’, ‘COG’, ‘DOG’]
As a bonus we can get the farthest: