How to approach this problem programmatically and efficiently?

I am quite stuck in this problem for a long. I am not able to approach this problem and make progress. However, based on my progress what I understood regarding the problem is:

  1. We are given a dictionary of words in which all words have the same length.
  2. We are given a beginWord and endWord and we have to convert beginWord into endWord with one transformation(one letter change) and the next obtained word must be present in the given wordlist.
  3. So we can consider a word as a node in the graph and all next node( 1 letter change ) as it’s an adjacent node in the graph.
  4. Now I think we have to find the shortest distance between the node i.e, beginWord and endWord.
    I am facing difficulty in doing these things programmatically.
    Thanks in advance :slight_smile:

Well Can you convert this in a bfs problem where you have to find the shortest distance between final and starting word. All dictionary words are intermediate words and a node exists between 2 words only if they differ by exactly 1 letter.

@tusharanand Quick check, is this resolved?

Okay I am re-attempting it. I will come back to you, if any issues :’)

hey closing this one. seems like your error resolved.

Closing this topic as there is no response since last 12 hours. Please feel free to create a new topic and post this question as a reference link in the description of the new topic.