← Back to problems LC 244 →

Shortest Word Distance II

LeetCode 244 • Medium • Design • Anduril

Design WordDistance: preprocess dict once; shortest(w1,w2) via two pointers on index lists.

TimeO(n) prep
SpaceO(n)
Word index
step
note
Ready
Press Play to walk the algorithm.