tech-interview-handbook/questions/04-synonyms.md

506 B

id title topics difficulty
4 Synonyms
graph
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
'''