package leetcode;

/**
 * https://leetcode.com/problems/sentence-similarity/
 */
public class Problem734 {
    public boolean areSentencesSimilar(String[] words1, String[] words2, String[][] pairs) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem734 prob = new Problem734();
        System.out.println(prob.areSentencesSimilar(
            new String[]{"great", "acting", "skills"},
            new String[]{"fine","drama","talent"},
            new String[][]{{"great", "fine"}, {"acting","drama"}, {"skills","talent"}}
        ));
    }
}

@@ -12,16 +12,113 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0A
 /**%0A * h
@@ -302,24 +302,1080 @@
     
-// TODO%0A
+if (words1.length != words2.length) %7B%0A            return false;%0A        %7D%0A        Map%3CString, Set%3CString%3E%3E map = new HashMap%3C%3E();%0A        for (String%5B%5D pair : pairs) %7B%0A            if (!map.containsKey(pair%5B0%5D)) %7B%0A                Set%3CString%3E set = new HashSet%3C%3E();%0A                set.add(pair%5B1%5D);%0A                map.put(pair%5B0%5D, set);%0A            %7D else %7B%0A                map.get(pair%5B0%5D).add(pair%5B1%5D);%0A            %7D%0A            if (!map.containsKey(pair%5B1%5D)) %7B%0A                Set%3CString%3E set = new HashSet%3C%3E();%0A                set.add(pair%5B0%5D);%0A                map.put(pair%5B1%5D, set);%0A            %7D else %7B%0A                map.get(pair%5B1%5D).add(pair%5B0%5D);%0A            %7D%0A        %7D%0A        for (int i = 0; i %3C words1.length; i++) %7B%0A            String word1 = words1%5Bi%5D;%0A            String word2 = words2%5Bi%5D;%0A            if (word1.equals(word2)) %7B%0A                continue;%0A            %7D%0A            if (!map.containsKey(word1)) %7B%0A                return false;%0A            %7D%0A            Set%3CString%3E set = map.get(word1);%0A            if (!set.contains(word2)) %7B%0A      
         
 retu
@@ -1362,32 +1362,34 @@
 %7B%0A              
+  
 return false;%0A  
@@ -1382,24 +1382,69 @@
 turn false;%0A
+            %7D%0A        %7D%0A        return true;%0A
     %7D%0A%0A    p
@@ -1784,16 +1784,480 @@
      ));
+ // true%0A        System.out.println(prob.areSentencesSimilar(%0A            new String%5B%5D%7B%22great%22, %22acting%22, %22skills%22%7D,%0A            new String%5B%5D%7B%22fine%22,%22drama%22,%22talent%22%7D,%0A            new String%5B%5D%5B%5D%7B%7B%22great%22, %22fine%22%7D, %7B%22acting%22,%22drama%22%7D%7D%0A        )); // false%0A        System.out.println(prob.areSentencesSimilar(%0A            new String%5B%5D%7B%22great%22, %22acting%22, %22skills%22%7D,%0A            new String%5B%5D%7B%22great%22,%22acting%22,%22skills%22%7D,%0A            new String%5B%5D%5B%5D%7B%7D%0A        )); // true
 %0A    %7D%0A%7D

Solve problem 734