Skip to content

Latest commit

 

History

History
45 lines (24 loc) · 969 Bytes

README_EN.md

File metadata and controls

45 lines (24 loc) · 969 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

...