package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/string-matching-in-an-array/
 */
public class Problem1408 {
    public List<String> stringMatching(String[] words) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1408 prob = new Problem1408();
        System.out.println(prob.stringMatching(new String[]{"mass","as","hero","superhero"})); // ["as","hero"]
        System.out.println(prob.stringMatching(new String[]{"leetcode","et","code"})); // ["et","code"]
        System.out.println(prob.stringMatching(new String[]{"blue","green","bu"})); // []
        System.out.println(prob.stringMatching(new String[]{"mass","as","hero","mas","superhero"})); // ["as","hero","mas"]
    }
}

@@ -33,13 +33,89 @@
 til.
+Array
 List;
+%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;
 %0A%0A/*
@@ -278,564 +278,437 @@
     
-// TODO%0A        return null
+Set%3CString%3E answer = new HashSet%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1408 prob = new Problem1408();%0A        System.out.println(prob.stringMatching(new String%5B%5D%7B%22mass%22,%22as%22,%22hero%22,%22superhero%22%7D)); // %5B%22as%22,%22hero%22%5D%0A        System.out.println(prob.stringMatching(new String%5B%5D%7B%22leetcode%22,%22et%22,%22code%22%7D)); // %5B%22et%22,%22code%22%5D%0A        System.out.println(prob.stringMatching(new String%5B%5D%7B%22blue%22,%22green%22,%22bu%22%7D)); // %5B%5D%0A        System.out.println(prob.stringMatching(new String%5B%5D%7B%22mass%22,%22as%22,%22hero%22,%22mas%22,%22superhero%22%7D)); // %5B%22as%22,%22hero%22,%22mas%22%5D
+for (int i = 0; i %3C words.length; i++) %7B%0A            for (int j = i + 1; j %3C words.length; j++) %7B%0A                if (words%5Bj%5D.contains(words%5Bi%5D)) %7B%0A                    answer.add(words%5Bi%5D);%0A                %7D%0A                if (words%5Bi%5D.contains(words%5Bj%5D)) %7B%0A                    answer.add(words%5Bj%5D);%0A                %7D%0A            %7D%0A        %7D%0A        return new ArrayList%3C%3E(answer);
 %0A   

Solve problem 1408