LC: 243. Shortest Word Distance - spiralgo/algorithms GitHub Wiki

243. Shortest Word Distance:

The Essence:

We need to keep in mind that the words can occur multiple times. So there can be multiple distances.

Details:

We should keep track of the distances and indices at each occurrence and find the minimum distance ever encountered using, for example, Math.min method.