Shortest Word Distance
LeetCode 243 • Easy • Arrays & Hashing
words = ["practice","makes","perfect","coding","makes"], word1="coding", word2="makes" → 1.
TimeO(n)
SpaceO(1)
i: —i1: —i2: —best: ∞
Current i
word1 (i1)
word2 (i2)
i—
best∞
Ready
Press Play or Step to walk the algorithm.