Given an array of strings wordsDict and two strings word1 and word2, return the shortest distance between the occurrences of word1 and word2 in the array.
Note:
word1andword2may be identical. When they are the same, they must refer to two distinct indices in the array.
Constraints:
wordsDict.length
wordsDict[i].length
wordsDict[i] consists of lowercase English letters.
word1 and word2 are in wordsDict.
Given an array of strings wordsDict and two strings word1 and word2, return the shortest distance between the occurrences of word1 and word2 in the array.
Note:
word1andword2may be identical. When they are the same, they must refer to two distinct indices in the array.
Constraints:
wordsDict.length
wordsDict[i].length
wordsDict[i] consists of lowercase English letters.
word1 and word2 are in wordsDict.