Shortest Word Distance
Problem
Given a list of words words and two query words word1 and word2, return the minimum distance between their occurrence indices in the list.
If words[i] == word1 and `words[j] == wor...
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
