mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-04-26 19:42:32 +08:00
506 B
506 B
id, title, topics, difficulty
| 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
'''