Skip to content

Files

Latest commit

 

History

History
48 lines (21 loc) · 872 Bytes

README_EN.md

File metadata and controls

48 lines (21 loc) · 872 Bytes

Description

You have a large text file containing words. Given any two words, find the shortest distance (in terms of number of words) between them in the file. If the operation will be repeated many times for the same file (but different pairs of words), can you optimize your solution?

Example:

Input: words = ["I","am","a","student","from","a","university","in","a","city"], word1 = "a", word2 = "student"

Output: 1

Note:

  • words.length <= 100000

Solutions

Python3

Java

...