sentence1
and sentence2
have different lengths, return false
.wordToSimilarWords
.[word1, word2]
in similarPairs
, add word2
to wordToSimilarWords[word1]
and word1
to wordToSimilarWords[word2]
.sentence1
using index i
:
sentence1[i]
equals sentence2[i]
, continue to the next word.sentence2[i]
is in the set wordToSimilarWords[sentence1[i]]
, continue to the next word.false
.true
.