← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given an array of strings wordsDict and two different strings word1 and word2 that both appear in the array. Return the minimum distance between any occurrence of word1 and any occurrence of word2 in wordsDict.
Input: wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "makes", word2 = "coding" Output: 3
Input: wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "makes", word2 = "makes" Output: 1
1 <= wordsDict.length <= 1001 <= wordsDict[i].length <= 10wordsDict[i] consists of lowercase English letters.word1 and word2 are in wordsDict and are distinct.