You, leetcode

LeetCode 79 (Hard). Word Ladder

Over the past two years I have completed all the "easy" LeetCode problems by making it a semi-serious hobby to grind away at it. I'm working through the "medium" problems now with occasional forays into the "hard" category.

Ancedotally it seems like the hard problems are often easier to complete than the medium ones. Sometimes with medium problems there seems to be a trick or non-obvious way to approach the problem, whereas with hard problems the solution seems clear even if it's complex and thus will require a bit of time to code up.

This "Word Ladder" problem was a ton of fun. You get a list of words and you find the shortest path of words where each step means a single letter difference. I immediately thought of this problem as a graph problem, and so that's how I approached it (using Dijkstra's algorithm).

When I write a program, I put some effort into writing good comments. For me that's part of the challenge and the fun, is thinking about what is worth commenting and what might even require commenting. As for the hypothetical audience of my comments, I guess it's an amalgam of my future self plus the poor soul who has to maintain my program at some future time!

The code listing and forum post are here: