NeetCode #158LC-244MediumArrays & Hashing
← Back to All Problems

#158 · #244 · Shortest Word Distance II(最短单词距离 II)

📌 Problem Statement & Constraints

Design a class that is initialised with an array of strings wordsDict and answers repeated queries shortest(word1, word2) returning the shortest distance between the two words. Constraints: 1 <= wordsDict.length <= 3 * 10^4; up to 10^4 queries.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!