j**l 发帖数: 2911 | 1 好像从来没有人贴过具体的思路,谁可以分析一下这个经典问题? |
c*********n 发帖数: 1057 | 2 coask
【在 j**l 的大作中提到】 : 好像从来没有人贴过具体的思路,谁可以分析一下这个经典问题?
|
C*Y 发帖数: 736 | |
j**l 发帖数: 2911 | 4 晕,下午Amazon第一轮电面就真的问了这道题,真是哪壶不开提哪壶。 |
l*****a 发帖数: 14598 | 5 shit
i wrote this for more than 3 hours last night....
class room
{
int roomnumber;
int type;//level,bed number and the other search criteria
int [12][31] status; //maybe not good,keep the reservationID
void MakeReservation();
void CancelReservation();
void CheckOut();
}
class ReservationInfo
{
int ReservationID;
char * CustomerName;
int RoomNumber;
date StartData;
data EndData;
int status; //00 reserved 01 canceled 10 checkin 11checkout
int price;
publi
【在 j**l 的大作中提到】 : 晕,下午Amazon第一轮电面就真的问了这道题,真是哪壶不开提哪壶。
|
l*****a 发帖数: 14598 | 6 I just use a list,so the search efficiency may not high.
if u want to get a high efficiency when search the empty room based
on the query.
1) you can use some other data structure
2) you can create different room list based on the type/level/bed
number...store them sorted.
then just find the intersection of different list..
【在 l*****a 的大作中提到】 : shit : i wrote this for more than 3 hours last night.... : class room : { : int roomnumber; : int type;//level,bed number and the other search criteria : int [12][31] status; //maybe not good,keep the reservationID : void MakeReservation(); : void CancelReservation(); : void CheckOut();
|
s********l 发帖数: 998 | 7 哇~ 赞一个~
【在 l*****a 的大作中提到】 : shit : i wrote this for more than 3 hours last night.... : class room : { : int roomnumber; : int type;//level,bed number and the other search criteria : int [12][31] status; //maybe not good,keep the reservationID : void MakeReservation(); : void CancelReservation(); : void CheckOut();
|