Algorithm · Uber · Easy
Minimum Separation Between Two Words You receive a string array wordsDict along with two distinct strings, word1 and word2, each of which is guaranteed to occur in that array. Find and return the smallest index gap between an occurrence of word1 and an occurrence of word2 within wordsDict. Examples Example 1: Input: wordsDict = ["sun","moon","star","cloud","rain"], word1 = "rain", word2 = "sun" Output: 4 Explanation: "sun" is at index 0 and "rain" is at index 4, so their…
Checking your access…