@@ -0,0 +1,815 @@
+package advanced.scan.window.lc243_shortestworddistance;%0A%0Aimport org.junit.jupiter.api.Assertions;%0Aimport org.junit.jupiter.api.Test;%0A%0A/**%0A */%0Apublic class Solution %7B%0A%0A    @Test%0A    void test() %7B%0A        Assertions.assertEquals(1, shortestDistance(%0A                new String%5B%5D%7B%22a%22, %22c%22, %22c%22, %22b%22, %22d%22, %22a%22, %22b%22%7D, %22a%22, %22b%22));%0A    %7D%0A%0A    public int shortestDistance(String%5B%5D words, String w1, String w2) %7B%0A        int min = Integer.MAX_VALUE, p1 = -1, p2 = -1;%0A        for (int i = 0; i %3C words.length; i++) %7B%0A            if (words%5Bi%5D.equals(w1)) %7B%0A                p1 = i;%0A                if (p2 != -1) min = Math.min(min, p1 - p2);%0A            %7D else if (words%5Bi%5D.equals(w2)) %7B%0A                p2 = i;%0A                if (p1 != -1) min = Math.min(min, p2 - p1);%0A            %7D%0A        %7D%0A        return min;%0A    %7D%0A%0A%7D%0A

shortest word distance