Doubt regarding solving graph problems in general


#1

In my first attempt I tried to construct the graph in bfs traversal along with counting the minimum steps to reach the last word , and then use it to generate solution using dfs.
However this had a “OUT OF HEAP SPACE” error.
I managed to do the problem by not constructing the graph and checking if two strings differ in more than one character.
What i’m concerned about is how should I guess that a graph need not be constructed ? What if the strings were 10000’s character long won’t checking if two strings differ in more than one character (again and again) give a TLE?
I will be really grateful if someone can address this query .


#2

I also have the same doubt


#3

For all position of the string generate all possible combination and check whether its exits in given dict or not.
Checking can be done in O(1) using hash map.

Also the most important trick of the question to exchange start and end because you will need to backtrack the sol to get the answer. If you does exchange start and end then you have to reverse your whole array for every path and this will be very costly.