📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

Blend面经+答案大放送

全局:

2018(10-12月) 码农类General 本科 实习@blend - 内推 - 技术电面 Onsite  | | Fail | 应届毕业生

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

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

x

您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies



  1. import copy
  2. def move(grid):
  3. def robotMove(grid, i, j):
  4. if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0]):
  5. return 0
  6. if grid[i][j] == 1:
  7. return 0  
  8. if i == len(grid)-1 and j == len(grid[0]) - 1:
  9. return 1  
  10. arr = copy.deepcopy(grid)
  11. arr[i][j] = 1
  12. return robotMove(arr,i-1,j) + robotMove(arr, i, j+1) + robotMove(arr, i,j-1) + robotMove(arr, i+1,j)

  13. return robotMove(grid, 0, 0)
复制代码




  1. def letterCombinations(self, digits):
  2.         if not digits:
  3.             return []
  4.         phoneMap = { '2' : "abc", '3': "def", '4':"ghi",
  5.            '5':"jkl", '6':"mno", '7':"pqrs", '8':"tuv",'9': "wxyz" }

  6.         result = []
  7.         self.dfs(digits, "", result,phoneMap)
  8.         return result

  9.     def dfs(self, digits, path, result,phoneMap):
  10.         if not digits and path:
  11.             result.append(path)
  12.             return
  13.         for letter in phoneMap[digits[0]]:
  14.             self.dfs(digits[1:], path+letter, result,phoneMap)

复制代码


  1. import random
  2. import copy
  3. class MineSweeper():
  4.     def __init__(self, row, col, mine_count):
  5.         self.board = [["-" for _ in range(col)] for _ in range(row)]
  6.         self.row = row
  7.         self.col = col
  8.         self.mines = self.place_mines(mine_count)
  9.         self.gameOver = False
  10.         self.visited = set()
  11.         self.iteration = 0
  12.         self.print_board()
  13.         self.print_mine()

  14.     def print_mine(self):
  15.         print("Mines -------------")
  16.         tmp = copy.deepcopy(self.board)
  17.         for (row, col) in self.mines:
  18.             tmp[row][col] = "X"
  19.         for row in tmp:
  20.             print(" ".join(row))        

  21.     def print_board(self):
  22.         print("Board at " + str(self.iteration)+ "th iteration: -----------------")
  23.         for row in self.board:
  24.             print(" ".join(row))
  25.         self.iteration += 1


  26.     def place_mines(self, mine_count):
  27.         cnt = 0
  28.         locations = set()
  29.         while cnt < mine_count:
  30.             row, col = self.generate_random()   
  31.             if (row, col) not in locations:
  32.                 cnt += 1
  33.                 locations.add((row, col))
  34.         return locations


  35.     def click(self, row = None, col = None):
  36.         if len(self.visited) == self.row*self.col:
  37.             print("You win")
  38.             self.gameOver = True
  39.             return

  40.         if row ==None and col ==None:
  41.             row, col = self.generate_random()
  42.             while (row, col) in self.visited:
  43.                 row, col = self.generate_random()
  44.         print("Clicked at number {0} row, number {1} col".format(row, col))
  45.         if (row, col) in self.mines:
  46.             self.board[row][col] = "X"
  47.             self.print_board()
  48.             print("Game over!")
  49.             self.gameOver = True
  50.             return
  51.         else:
  52.             self.reveal(row, col)
  53.             self.print_board()

  54.     def reveal(self, row, col):
  55.         mine_count = 0
  56.         self.visited.add((row, col))

  57.         for i in range(row-1, row+2):
  58.             for j in range(col-1, col+2):
  59.                 if (i, j) in self.mines:
  60.                     mine_count += 1
  61.         if mine_count == 0:
  62.             self.board[row][col] = "0"
  63.         else:
  64.             self.board[row][col] = str(mine_count)
  65.             return
  66.         for i in range(row-1, row+2):
  67.             for j in range(col-1, col+2):
  68.                 if 0 <= i < self.row and 0 <= j < self.col and (i, j) not in self.visited:
  69.                     self.reveal(i, j)

  70.     def generate_random(self):
  71.         return random.randint(0, self.row-1), random.randint(0, self.col-1)


  72. if __name__ == "__main__":
  73.     while True:
  74.         config = input("Enter the number of rows, columns of the board size and mines with a space in between")
  75.         config = config.strip().split()
  76.         if len(config) != 3:
  77.             print("Invalid input.")
  78.             continue
  79.         row, col, mines = int(config[0]), int(config[1]), int(config[2])
  80.         minesweeper = MineSweeper(row, col, mines)

  81.         while not minesweeper.gameOver:
  82.             click = input("Enter row number and col number you want to click.").strip().split()
  83.             row, col = int(click[0]) , int(click[1])
  84.             minesweeper.click(row, col)   

复制代码



[/hide]

求大米呀,可怜的我只有15个大米




补充内容 (2018-11-26 23:14):
请求版主,删掉这个帖子的第一题分数到小数的code吗?或者删掉整个帖子也行。因为有朋友照抄了我的的code,刚好同一个面试官,被面试官怀疑,然后挂了。不想害地里的....好后悔发了这个。

评分

参与人数 5大米 +118 收起 理由
modifiedname + 100
stupidradar + 3 给你点个赞!
irenezh + 5 给你点个赞!
捣乱 + 5 给你点个赞!
amethlex + 5 给你点个赞!

查看全部评分


上一篇:Rubrik 电面
下一篇:二西格玛电面新题
推荐
stupidradar 2018-11-26 23:25:21 | 只看该作者
全局:
我觉得分享的初心是好的,照抄的行为是自己作死,准备面试的时候找找面经无可厚非,但是面的时候还想直接拿来抄我觉得不能怪楼主的
回复

使用道具 举报

🔗
 楼主| lurukami 2018-11-24 04:43:11 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies

评分

参与人数 1大米 +5 收起 理由
amethlex + 5 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
 楼主| lurukami 2018-11-26 10:43:33 | 只看该作者
全局:
照抄会被发现的,请自重
回复

使用道具 举报

🔗
 楼主| lurukami 2018-11-26 13:51:20 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
回复

使用道具 举报

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

本版积分规则

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