泡菜斯坦,# Joke - 肚皮舞运动
b*i
1 楼
find a intersection to build office so that the sum of all employees’
commute distances is minimum. (the map is represented as a m*n grid, you
are given each employee’s coordination, they can only move in up-down and
left-right directions)
这是Google一道面试题。我能想到的就是从每个employee做BFS,再求出非employee的
格子的最短路径之和。找个和最小的格子。请问这题还有更简单的方法吗?
commute distances is minimum. (the map is represented as a m*n grid, you
are given each employee’s coordination, they can only move in up-down and
left-right directions)
这是Google一道面试题。我能想到的就是从每个employee做BFS,再求出非employee的
格子的最短路径之和。找个和最小的格子。请问这题还有更简单的方法吗?