a***o 发帖数: 19 | 1 我这周二有个面试,请大家帮忙看看下面这道算法题,谢谢!
You are a parking lot attendant in a lot that has one open spot, and you
want to move the cars from their original positions into a new arrangement.
Create a program that will print out instructions on how to move the cars
most efficiently. |
l*****a 发帖数: 14598 | 2 parking lot有什么限制条件
比方随便两辆车,都可以通过那个open lot交换嘛?
arrangement.
cars
【在 a***o 的大作中提到】 : 我这周二有个面试,请大家帮忙看看下面这道算法题,谢谢! : You are a parking lot attendant in a lot that has one open spot, and you : want to move the cars from their original positions into a new arrangement. : Create a program that will print out instructions on how to move the cars : most efficiently.
|
v********w 发帖数: 136 | 3 好像就是只能swap的排序问题,从第一个车位起,不断的把这个车位上的车换到应该的
位置,对的话就
看下一个
arrangement.
cars
【在 a***o 的大作中提到】 : 我这周二有个面试,请大家帮忙看看下面这道算法题,谢谢! : You are a parking lot attendant in a lot that has one open spot, and you : want to move the cars from their original positions into a new arrangement. : Create a program that will print out instructions on how to move the cars : most efficiently.
|
d**e 发帖数: 6098 | 4 如果是telnet,本版 48877 版
如果是 web, http://mitbbs.com/article_t/JobHunting/31550447.html
据里面讨论的跟这个题相似
.
【在 a***o 的大作中提到】 : 我这周二有个面试,请大家帮忙看看下面这道算法题,谢谢! : You are a parking lot attendant in a lot that has one open spot, and you : want to move the cars from their original positions into a new arrangement. : Create a program that will print out instructions on how to move the cars : most efficiently.
|
b******v 发帖数: 1493 | 5 假如有三辆车 1, 5, 7 ,它们的新位置分别为5, 7, 1,
则可以这样做(其中V表示空位)
1->V
7->1
5->7
V->5
假设原位置为a[0..(N-1)], 对应的新位置为b[0..(N-1)]
则基本上只要对每个类似上面例子中的圈做类似操作即可
.
【在 a***o 的大作中提到】 : 我这周二有个面试,请大家帮忙看看下面这道算法题,谢谢! : You are a parking lot attendant in a lot that has one open spot, and you : want to move the cars from their original positions into a new arrangement. : Create a program that will print out instructions on how to move the cars : most efficiently.
|
a***o 发帖数: 19 | |