回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

roblox 第一轮三方面试

全局:

2020(10-12月) 码农类General 硕士 全职@roblox - 猎头 - 技术电面  | | Other | 在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
本帖最后由 lchena 于 2020-10-19 05:51 编辑

第一轮面试是Karak 第三方1小时面试前5分钟简单介绍自己tech背景
然后10分
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
hildPairs 和两个nod。

3. 找出最远距离的祖先

input是parentChildPairs和一个node



评分

参与人数 2大米 +10 收起 理由
nfsbfs + 2 很有用的信息!
匿名用户-NO0R1 + 8

查看全部评分


上一篇:hrt algo dev 电面 跪求onsite经验
下一篇:JP Morgan OA面经分享
🔗
Eason1220 2020-10-19 10:10:12 | 只看该作者
全局:
感觉和楼主面的同样一个人。。。。也是面试这些题目
回复

使用道具 举报

🔗
johnnywsd 2020-10-26 05:12:20 | 只看该作者
全局:
  1. # coding=utf-8
  2. """
  3. 找出有零或一个parent 的node
  4. input是一个二维array represent the parentChildPairs,
  5. 每个pair input[0] 是input[1] 的parent,比如 {{1,2}}
  6. 表示1 是2 的parent.
  7. """

  8. from collections import defaultdict

  9. def find_zero_one_parent_nodes(arr):
  10.     ct = defaultdict(set)
  11.     for p, c in arr:
  12.         ct[c].add(p)
  13.    
  14.     res = set()
  15.     for p, c in arr:
  16.         if p not in ct:
  17.             res.add(p)
  18.         if len(ct[c]) == 1:
  19.             res.add(c)
  20.     return res


  21. import unittest
  22. class Test(unittest.TestCase):

  23.     def test_1(self):
  24.         arr = [(1, 2), (1, 2), (2, 3), (1, 3)]
  25.         actual = find_zero_one_parent_nodes(arr)
  26.         expect = set([1, 2])
  27.         self.assertEqual(actual, expect)
  28.         print(actual)


  29. if __name__ == '__main__':
  30.     unittest.main(verbosity=2)
复制代码

  1. # coding=utf-8
  2. """
  3. 找出有零或一个parent 的node
  4. input是一个二维array represent the parentChildPairs,
  5. 每个pair input[0] 是input[1] 的parent,比如 {{1,2}}
  6. 表示1 是2 的parent.
  7. 找出两个node是否有共同的祖先
  8. """

  9. from collections import defaultdict
  10. from collections import deque

  11. def have_common_ancestor(arr, p1, p2):
  12.     cp_graph = defaultdict(set)
  13.     for p, c in arr:
  14.         cp_graph[c].add(p)
  15.     p1_ancestors = get_ancestors(cp_graph, p1)
  16.     p2_ancestors = get_ancestors(cp_graph, p2)
  17.     return bool(p1_ancestors & p2_ancestors)

  18. def get_ancestors(cp_graph, p):
  19.     visited = set()
  20.     queue = deque([p])
  21.     res = set()
  22.     while queue:
  23.         n = queue.popleft()
  24.         res.add(n)
  25.         for nxt in cp_graph.get(n) or []:
  26.             if nxt not in visited:
  27.                 visited.add(nxt)
  28.                 queue.append(nxt)
  29.     return res


  30. import unittest
  31. class Test(unittest.TestCase):

  32.     def test_1(self):
  33.         arr = [(1, 2), (1, 2), (2, 3), (1, 3)]
  34.         actual = have_common_ancestor(arr, 1, 2)
  35.         expect = True
  36.         self.assertEqual(actual, expect)
  37.         print(actual)

  38.     def test_2(self):
  39.         arr = [(1, 2), (1, 2), (2, 3), (1, 3)]
  40.         actual = have_common_ancestor(arr, 1, 4)
  41.         expect = False
  42.         self.assertEqual(actual, expect)
  43.         print(actual)

  44.     def test_3(self):
  45.         arr = [(1, 2), (1, 2), (2, 3), (1, 3), (4, 5), (5, 6)]
  46.         actual = have_common_ancestor(arr, 2, 6)
  47.         expect = False
  48.         self.assertEqual(actual, expect)
  49.         print(actual)

  50. if __name__ == '__main__':
  51.     unittest.main(verbosity=2)
复制代码

  1. # coding=utf-8
  2. """
  3. 找出有零或一个parent 的node
  4. input是一个二维array represent the parentChildPairs,
  5. 每个pair input[0] 是input[1] 的parent,比如 {{1,2}}
  6. 表示1 是2 的parent. no cycle
  7. 找出最远距离的祖先
  8. """

  9. from collections import defaultdict
  10. from collections import deque

  11. def farest_ancestors(arr, n):
  12.     cp_graph = defaultdict(set)
  13.     for p, c in arr:
  14.         cp_graph[c].add(p)
  15.     print(cp_graph)
  16.     p_ancestors = get_farest_ancestors(cp_graph, n)
  17.     return p_ancestors

  18. def get_farest_ancestors(cp_graph, node):
  19.     queue = deque([node])
  20.     res = set([node])
  21.     while queue:
  22.         len_queue = len(queue)
  23.         res.clear()
  24.         for _ in range(len_queue):
  25.             n = queue.popleft()
  26.             res.add(n)
  27.             for nxt in cp_graph.get(n) or []:
  28.                 queue.append(nxt)
  29.     return res


  30. import unittest
  31. class Test(unittest.TestCase):

  32.     def test_1(self):
  33.         arr = [(1, 2), (1, 2), (2, 3), (1, 3)]
  34.         actual = farest_ancestors(arr, 3)
  35.         expect = set([1])
  36.         print(actual)
  37.         self.assertEqual(actual, expect)

  38.     def test_2(self):
  39.         arr = [(1, 2), (1, 2), (2, 3), (1, 3)]
  40.         actual = farest_ancestors(arr, 4)
  41.         expect = set([4])
  42.         print(actual)
  43.         self.assertEqual(actual, expect)

  44.     def test_3(self):
  45.         arr = [(1, 2), (1, 2), (2, 3), (1, 3), (4, 5), (5, 6)]
  46.         actual = farest_ancestors(arr, 6)
  47.         expect = set([4])
  48.         print(actual)
  49.         self.assertEqual(actual, expect)

  50.     def test_4(self):
  51.         arr = [(1, 2), (3, 2), (4, 1), (5, 3)]
  52.         actual = farest_ancestors(arr, 2)
  53.         expect = set([4, 5])
  54.         print(actual)
  55.         self.assertEqual(actual, expect)

  56. if __name__ == '__main__':
  57.     unittest.main(verbosity=2)
复制代码
回复

使用道具 举报

🔗
vivianwr 2020-11-3 07:57:22 | 只看该作者
全局:
和你面到了一样的题呢!
回复

使用道具 举报

🔗
woshilxd912 2020-11-10 15:33:14 | 只看该作者
全局:
我也面到了一模一样的题目
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表