506 B
506 B
id | title | topics | difficulty | |
---|---|---|---|---|
4 | Synonyms |
|
medium |
Question
'''
Given a list of synonym pairs, determine if two words are synonymous.
Synonyms have a symmetric and transitive relation. i.e. if a <-> b and b <-> c, a <-> c.
Input:
[["computer", "laptop"]]
"computer"
"laptop"
Output: true
Input:
[["computer", "laptop"], ["laptop", "pc"]]
"computer"
"pc"
Output: true
Input:
[["computer", "laptop"], ["laptop", "pc"], ["tablet", "iPad"]]
"computer"
"iPad"
Output: false
'''