Shortest Word Distance II

Given an immutable list of words wordsDict, implement a WordDistance class:

  • WordDistance(wordsDict): initializes the object with the list.
  • shortest(word1, word2): returns the minimum abso...

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: