Skip to content

245. Shortest Word Distance III #36

@altay9

Description

@altay9

https://leetcode.com/problems/shortest-word-distance-iii

Burada, bir string listesi (wordsDict) veriliyor.
İki tane de ayrı string (word1, word2 ) veriliyor.
Bu stringlerin listede birbirlerine olan uzaklıklarını hesaplamamız isteniyor.

Eğer herhangi bir sözcük listede tekrar ediyorsa, birden fazla uzaklık bulunacaktır.
Bizden istenen en kısa uzaklığı bulmamız.

Not: word1 ve word2 aynı stringe eşit olabilir.

Input: wordsDict = ["practice", "makes", "perfect", "coding", "makes"],
word1 = "makes", word2 = "coding"
Output: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions