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

Google电面

头像被屏蔽
提示: 作者被禁止或删除 内容自动屏蔽

上一篇:Zenefits电面面经
下一篇:G家front-end电面

本帖被以下淘专辑推荐:

🔗
hulahu 2015-10-21 06:29:23 | 只看该作者
全局:
第三题, 老鼠那道, 可以说说解法吗?
回复

使用道具 举报

🔗
spiritrhy 2015-10-22 02:33:36 | 只看该作者
全局:
楼主第三题能给个sample 输出吗, 是要输出所有路径么
回复

使用道具 举报

🔗
tangvictor 2015-10-22 23:31:20 | 只看该作者
全局:
我写了下老鼠的题,返回所有冲突的情况。老鼠用1-n表示的,冲突里每个list元素代表每个结点上的老鼠可能性。
  1. def mouse(n):
  2.         res = []
  3.         mouse = [i for i in range(1, n + 1)]
  4.         line = [[] for i in range(n)]
  5.         helper(line, mouse, res, 0)
  6.         return res

  7. def helper(line, mouse, res, index):
  8.         if index == len(mouse):
  9.                 for l in line:
  10.                         if len(l) > 1:   # means colli
  11.                                 copy = []
  12.                                 for l in line:
  13.                                         copy.append(list(l))
  14.                                 res.append(copy)
  15.                 return

  16.         line[(index - 1) % len(mouse)].append(mouse[index])
  17.         helper(line, mouse, res, index + 1)
  18.         line[(index - 1) % len(mouse)].pop()


  19.         line[(index + 1) % len(mouse)].append(mouse[index])
  20.         helper(line, mouse, res, index + 1)
  21.         line[(index + 1) % len(mouse)].pop()
复制代码
回复

使用道具 举报

🔗
snowwolf 2015-10-22 23:51:23 | 只看该作者
全局:
一次电面4道题?这量也太大了吧?1个小时吗?
回复

使用道具 举报

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

本版积分规则

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