sentence1
and sentence2
have the same length. If not, return false
.dsu
.similarPairs
and for each pair [x, y]
, perform the following:
a. Add x
and y
to dsu
if not already present.
b. Union x
and y
in dsu
.i
of sentence1
and sentence2
:
a. If sentence1[i]
equals sentence2[i]
, continue to the next index.
b. If dsu.find(sentence1[i])
equals dsu.find(sentence2[i])
, continue to the next index.
c. If neither condition is met, return false
.true
.