|
3 | 3 | import java.util.HashMap;
|
4 | 4 | import java.util.Map;
|
5 | 5 |
|
6 |
| -/** |
7 |
| - * 737. Sentence Similarity II |
8 |
| - * |
9 |
| - * Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar. |
10 |
| - * For example, words1 = ["great", "acting", "skills"] and words2 = ["fine", "drama", "talent"] are similar, |
11 |
| - * if the similar word pairs are pairs = [["great", "good"], ["fine", "good"], ["acting","drama"], ["skills","talent"]]. |
12 |
| - * Note that the similarity relation is transitive. |
13 |
| - * |
14 |
| - * For example, if "great" and "good" are similar, and "fine" and "good" are similar, then "great" and "fine" are similar. |
15 |
| - * Similarity is also symmetric. For example, "great" and "fine" being similar is the same as "fine" and "great" being similar. |
16 |
| - * Also, a word is always similar with itself. For example, the sentences words1 = ["great"], words2 = ["great"], pairs = [] are similar, even though there are no specified similar word pairs. |
17 |
| - * Finally, sentences can only be similar if they have the same number of words. So a sentence like words1 = ["great"] can never be similar to words2 = ["doubleplus","good"]. |
18 |
| -
|
19 |
| - Note: |
20 |
| -
|
21 |
| - The length of words1 and words2 will not exceed 1000. |
22 |
| - The length of pairs will not exceed 2000. |
23 |
| - The length of each pairs[i] will be 2. |
24 |
| - The length of each words[i] and pairs[i][j] will be in the range [1, 20]. |
25 |
| -
|
26 |
| - */ |
27 | 6 | public class _737 {
|
28 | 7 | public static class Solution1 {
|
29 | 8 | public boolean areSentencesSimilarTwo(String[] words1, String[] words2, String[][] pairs) {
|
|
0 commit comments