注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
Roblox外包phone interview给karat.
一共三小问
-第一问:给你一串(parent, child) 组合, 找出所有有0个parent和1个parent的序号。
举例:
3 is a child of 1 and 2, and 5 is a child of 4:
parentChildPairs = [ (1, 3), (2, 3), (3, 6), (5, 6),
(5, 7), (4, 5), (4, 8), (tChildPairs, 7) => 4
findEarliestAncestor(parentChildPairs, 6) => 11
findEarliestAncestor(parentChildPairs, 1) => null or -1
我全程用Hashmap做了,他们不是很要求优化,只要能跑通并且分析时间复杂度就行。
|