本帖最后由 825344491 于 2025-6-15 13:10 编辑
好久没有上线了,大米掉光了,看不了帖子了,所以求各位加个米!文章没有设积分门槛~
面试官
一个稍微有一点口音的印度男性,很好交流
面试流程
和一致(详情见下图)。连自我介绍都没问,直接扔一道算法题开始做。算法题做完之后问了一个最有挑战性的项目,然后挖这个项目的技术细节
算法题
一个矩阵题,找符合条件的位置,在上找到了原题:
Given two inputs,
First input is the location map, a 2D array
| O | E | E | E | X |
| E | O | X | X | X |
| E | E | E | E | E |
| X | E | O | E | E |
| X | E | X | E | X |
O = Robot, E = Empty, X = blocker
Second input is the query. It’s a 1D array consisting of distance to the closest blocker in the order from left, top, bottom and right
[2, 2, 4, 1] -> This means distance of 2 to the left blocker, 2 to the top blocker, 4 to the bottom blocker and 1 to the right blocker
Map boundary is also considered blocker, meaning if the robot hits the boundary it also means it’s hitting the blocker.
Task: Write a function that takes these two inputs and returns the index of the robots (if any) that matches the query that we’re looking for.
Matrix example: [['O','E','E','E','X'],['E' down[r][c] = 1
else:
down[r][c] = count + 1
count += 1
# Now scan all robot positions and compare with query
result = []
for r in range(rows):
for c in range(cols):
if grid[r][c] == 'O':
distances = [
left[r][c],
up[r][c],
down[r][c],
right[r][c]
]
if distances == query:
result.append([r, c])
return result
``` |