word ladder
The obvious O(n^2 * word len) exists. The tricky idea to assign the same node id to wildcard patterns.
hot → makes 3 nodes → *ot, h*t, ho* and you can give each one the same id. It’s done via map so you don’t really build a graph.
bias: you don’t need a dist array if you’re just tracking one end ( in bfs ) also removing the vis bucket from possible patterns makes it faster.