Leetcode 245. Shortest Word Distance III
Given a list of words and two target words (which may be the same), find the minimum index distance between any occurrence of the two targets; if the targets are identical, compute the smallest distance between two distinct occurrences of that word. This is typically solved by a single pass tracking last-seen positions of the targets to minimize index difference.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.