LeetCode
Shortest Word Distance II
Click
here
for an explanation.