← 返回 microsoft 的题目列表Detect Kinship via Common Ancestor in Family Database
类型:online_judge
microsoft
Given a database that stores direct family relationships of a city's population, design an algorithm to determine if any two given people have a kinship, meaning there is a common ancestor. The algorithm should complete in reasonable time.
Example
Input
4
1 2
2 3
3 4