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

google面试

全局:

2014(1-3月) 码农类General 硕士 全职@google - 猎头 - Onsite  | | Other |

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

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

x
早上错过了班车,迟到了半个小时。妈蛋,果然跟google没缘分。
到了之后逛了一圈,不错,啥都有:coffee sh
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
:14px">面完了滚出,给了一个瓶子,还有五块钱的google store卡。。。
午饭挺好吃的。下次有机会去,一定得好好吃一顿

评分

参与人数 2大米 +53 收起 理由
CooLife + 3 不错
yanyanlr + 50

查看全部评分


上一篇:Samsung Cloud/Server team面试
下一篇:HP vertica 面经

本帖被以下淘专辑推荐:

🔗
iamchrisa 2014-2-19 06:26:34 | 只看该作者
全局:
齐活...楼主哪里人?我以前经常用"齐活"这个词,哈哈
回复

使用道具 举报

🔗
猫咪老师 2014-3-2 07:14:18 | 只看该作者
全局:
多谢楼主分享~~去一次onsite这辈子job hunting就值了~
回复

使用道具 举报

🔗
johnnywsd 2014-4-7 07:25:44 | 只看该作者
全局:
  1. class Grid(object):

  2.     def __init__(self, grid):
  3.         self._grid = grid
  4.         self._m = len(grid)
  5.         self._n = len(grid[0])

  6.     def _get_children(self, i, j):
  7.         res = {}
  8.         for p in [-1, 0, 1]:
  9.             for q in [-1, 0, 1]:
  10.                 if p == q == 0:
  11.                     continue
  12.                 ii = i + p
  13.                 jj = j + q
  14.                 if 0 <= ii < self._m and 0 <= jj < self._n:
  15.                     res[(ii, jj)] = self._grid[ii][jj]
  16.         return res

  17.     def find_path(self, word):
  18.         self._visited = set()
  19.         res = []
  20.         for i in range(self._m):
  21.             for j in range(self._n):
  22.                 self._results = []
  23.                 self._find_path_aux(0, word, [], i, j)
  24.                 res.extend(self._results[:])
  25.         return res

  26.     def _find_path_aux(self, idx, word, one_result, i, j):
  27.         if idx == len(word) - 1:
  28.             target = word[idx]
  29.             if target == self._grid[i][j] and ((i, j) not in self._visited):
  30.                 self._results.append(one_result + [(i, j)])
  31.         else:
  32.             # 0 <= idx < len(word) - 1
  33.             target = word[idx]
  34.             if target == self._grid[i][j] and ((i, j) not in self._visited):
  35.                 self._visited.add((i, j))
  36.                 children = self._get_children(i, j)
  37.                 for key in children:
  38.                     ii = key[0]
  39.                     jj = key[1]
  40.                     self._find_path_aux(idx + 1, word, one_result + [(i, j)],
  41.                                         ii, jj)
  42.                 self._visited.remove((i, j))
  43.             else:
  44.                 return
复制代码
  1. # -*- coding: utf-8 -*-
  2. import unittest
  3. from solution import Grid


  4. class Test(unittest.TestCase):

  5.     def test1(self):
  6.         word = 'dog'
  7.         grid = ['dogo', 'oodo', 'gogo', 'oooo']
  8.         grid = ['dogo', 'xxxx', 'xxxx', 'xxxx']
  9.         grid = [[y for y in x] for x in grid]
  10.         s = Grid(grid)
  11.         res = s.find_path(word)
  12.         print res

  13.     def test2(self):
  14.         word = 'dog'
  15.         grid = ['dogo', 'oodo', 'gogo', 'oooo']
  16.         grid = [[y for y in x] for x in grid]
  17.         s = Grid(grid)
  18.         res = s.find_path(word)
  19.         print res
  20. if __name__ == '__main__':
  21.     unittest.main(verbosity=2)
复制代码
回复

使用道具 举报

🔗
johnnywsd 2014-4-7 07:27:03 | 只看该作者
全局:
  1. class Grid(object):

  2.     def __init__(self, grid):
  3.         self._grid = grid
  4.         self._m = len(grid)
  5.         self._n = len(grid[0])

  6.     def _get_children(self, i, j):
  7.         res = {}
  8.         for p in [-1, 0, 1]:
  9.             for q in [-1, 0, 1]:
  10.                 if p == q == 0:
  11.                     continue
  12.                 ii = i + p
  13.                 jj = j + q
  14.                 if 0 <= ii < self._m and 0 <= jj < self._n:
  15.                     res[(ii, jj)] = self._grid[ii][jj]
  16.         return res

  17.     def find_path(self, word):
  18.         self._visited = set()
  19.         res = []
  20.         for i in range(self._m):
  21.             for j in range(self._n):
  22.                 self._results = []
  23.                 self._find_path_aux(0, word, [], i, j)
  24.                 res.extend(self._results[:])
  25.         return res

  26.     def _find_path_aux(self, idx, word, one_result, i, j):
  27.         if idx == len(word) - 1:
  28.             target = word[idx]
  29.             if target == self._grid[i][j] and ((i, j) not in self._visited):
  30.                 self._results.append(one_result + [(i, j)])
  31.         else:
  32.             # 0 <= idx < len(word) - 1
  33.             target = word[idx]
  34.             if target == self._grid[i][j] and ((i, j) not in self._visited):
  35.                 self._visited.add((i, j))
  36.                 children = self._get_children(i, j)
  37.                 for key in children:
  38.                     ii = key[0]
  39.                     jj = key[1]
  40.                     self._find_path_aux(idx + 1, word, one_result + [(i, j)],
  41.                                         ii, jj)
  42.                 self._visited.remove((i, j))
  43.             else:
  44.                 return
复制代码

  1. # -*- coding: utf-8 -*-
  2. import unittest
  3. from solution import Grid


  4. class Test(unittest.TestCase):

  5.     def test1(self):
  6.         word = 'dog'
  7.         grid = ['dogo', 'oodo', 'gogo', 'oooo']
  8.         grid = ['dogo', 'xxxx', 'xxxx', 'xxxx']
  9.         grid = [[y for y in x] for x in grid]
  10.         s = Grid(grid)
  11.         res = s.find_path(word)
  12.         print res

  13.     def test2(self):
  14.         word = 'dog'
  15.         grid = ['dogo', 'oodo', 'gogo', 'oooo']
  16.         grid = [[y for y in x] for x in grid]
  17.         s = Grid(grid)
  18.         res = s.find_path(word)
  19.         print res
  20. if __name__ == '__main__':
  21.     unittest.main(verbosity=2)
复制代码


回复

使用道具 举报

🔗
shire1989 2014-5-9 05:58:27 | 只看该作者
全局:
找字符串查重的问题
什么意思?
回复

使用道具 举报

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

本版积分规则

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