avatar
G家面试题请教# JobHunting - 待字闺中
j*n
1
1.
Given multiple printers on a grid map, find the location to place papers
such that the sum of distance from the
paper to all printers is minimal; note that there are obstacles in the grid
map. What if there is no obstacles?
2
2d array *代表障碍物 #代表货物 空白就是正常的路

如何找到一个点为出发点 能实现总共取货路径最短? 每次只能拿一个货物,遇到障碍
需要绕开,拿到以后要放回出发点,然后再取另一个
******
* # *
* *** *
* *
* ** *
* # #*
** ****
如果没有障碍物,就是曼哈顿最短距离,http://stackoverflow.com/questions/10402087/algorithm-for-minimum-manhattan-distance,如果有障碍物,什么算法比较好? 大牛请解惑
avatar
P*L
2
2 用 BFS?

grid

【在 j*********n 的大作中提到】
: 1.
: Given multiple printers on a grid map, find the location to place papers
: such that the sum of distance from the
: paper to all printers is minimal; note that there are obstacles in the grid
: map. What if there is no obstacles?
: 2
: 2d array *代表障碍物 #代表货物 空白就是正常的路
: 问
: 如何找到一个点为出发点 能实现总共取货路径最短? 每次只能拿一个货物,遇到障碍
: 需要绕开,拿到以后要放回出发点,然后再取另一个

avatar
j*n
3
1和2其实是一样的题,都有在有障碍物的情况下,求一点到其他已知点的最小距离。
BFS肯定是用BFS, 但BFS怎么做好呢? 比如第2题,一种方法对所有 '#‘做BFS,另一
种方法是从所有空白格做BFS. 不过都不efficient, 有什么好办法吗?

【在 P*******L 的大作中提到】
: 2 用 BFS?
:
: grid

avatar
l*i
4
从货物出发去BFS
avatar
x*0
5
有障碍物,用BFS 算每个点到所有打印机/货物的距离和?这不是标准的brute force么
。。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。