注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
回馈地里,
前段时间的面经, 只记了第三题的题干, 45min写了三题, 时间还是比较紧张的, 祝大家好运~
Suppose we have some input data describing a graph of relationships between parents and children over multiple generations. The data is formatted as a list of (parent, child) pairs, where each individual is assigned a unique positive integer identifier.
For example, in this diagr) => 14
findEarliestAncestor(pairs1, 6) => 14
findEarliestAncestor(pairs1, 15) => 2
findEarliestAncestor(pairs1, 14) => null or -1
findEarliestAncestor(pairs1, 11) => 14 |