Design a parking lot.
see CC150 OO Design for details.
1) <code>n</code> levels, each level has <code>m</code> rows of spots and each row has <code>k</code> spots.So each level has <code>m</code> x <code>k</code> spots.
2) The parking lot can park motorcycles, cars and buses
3) The parking lot has motorcycle spots, compact spots, and large spots
4) Each row, motorcycle spots id is in range<code>[0,k/4)(0 is included, k/4 is not included)</code>, compact spots id is in range <code>[k/4,k/4*3)</code> and large spots id is in range <code>[k/4*3,k)</code>.
5) A motorcycle can park in any spot
6) A car park in single compact spot or large spot
7) A bus can park in five large spots that are consecutive and within same row. it can not park in small spots
Have you met this question in a real interview?
Yes
Example
level=1, num_rows=1, spots_per_row=11
parkVehicle("Motorcycle_1") // return true
parkVehicle("Car_1") // return true
parkVehicle("Car_2") // return true
parkVehicle("Car_3") // return true
parkVehicle("Car_4") // return true
parkVehicle("Car_5") // return true
parkVehicle("Bus_1") // return false
unParkVehicle("Car_5")
parkVehicle("Bus_1") // return true
LintCode的這道題的C++的OJ應該有問題,因為我的代碼在本地調試都正确,不知道為何通過不了OJ,有沒有大神持有同樣的觀點?