One Pager Cheat Sheet

  • The problem is to find the shortest sequence of words with a one letter difference between successive words, which transforms a given startW to a given endW using words from a provided dictionary, with time complexity of O((m^2)*n) and space complexity of O(m*n).
  • We can solve the problem of finding the shortest sequence of words between a start state startW and a goal state endW by using a queue data structure to do a breadth first search on an undirected graph.
  • The word ladder can be solved with a simple breadth-first search algorithm with a time complexity of (O(m^2n)) and space complexity of O(mn).

This is our final solution.

To visualize the solution and step through the below code, click Visualize the Solution on the right-side menu or the VISUALIZE button in Interactive Mode.

JAVASCRIPT

Great job getting through this. Let's move on.

If you had any problems with this tutorial, check out the main forum thread here.