Given two arrays of strings sentence1 and sentence2, and an array of string pairs similarPairs where each similarPairs[i] = [x_i, y_i] indicates that the words x_i and y_i are similar, determine if sentence1 and sentence2 are similar.
Two sentences are similar if:
They have the same length.
For each valid index i, the word sentence1[i] is similar to sentence2[i].
Similarity is an equivalence relation:
Every word is similar to itself.
If word
If word
Return true if sentence1 and sentence2 are similar, and false otherwise.
Note: Similarity relation is transitive, unlike Sentence Similarity I.
Constraints:
sentence1.length, sentence2.length
sentence1[i].length, sentence2[i].length
sentence1[i] and sentence2[i] consist of lowercase and uppercase English letters.
similarPairs.length
similarPairs[i].length
x_i.length, y_i.length
x_i and y_i consist of English letters.
Given two arrays of strings sentence1 and sentence2, and an array of string pairs similarPairs where each similarPairs[i] = [x_i, y_i] indicates that the words x_i and y_i are similar, determine if sentence1 and sentence2 are similar.
Two sentences are similar if:
They have the same length.
For each valid index i, the word sentence1[i] is similar to sentence2[i].
Similarity is an equivalence relation:
Every word is similar to itself.
If word
If word
Return true if sentence1 and sentence2 are similar, and false otherwise.
Note: Similarity relation is transitive, unlike Sentence Similarity I.
Constraints:
sentence1.length, sentence2.length
sentence1[i].length, sentence2[i].length
sentence1[i] and sentence2[i] consist of lowercase and uppercase English letters.
similarPairs.length
similarPairs[i].length
x_i.length, y_i.length
x_i and y_i consist of English letters.