Shortest Word Distance II

Design a WordDistance data structure. It is initialized with a word array wordsDict, then must efficiently answer multiple queries for the shortest distance between any occurrence of two words.

T...

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: