Re: [闲聊] 每日LeetCode

楼主: Rushia (みけねこ的鼻屎)   2023-05-29 20:46:05
https://leetcode.com/problems/design-parking-system/description/
1603. Design Parking System
设计一个停车场类别,他有大、中、小三种大小的车位,分别对应1、2、3的类型
1.ParkingSystem(int big, int medium, int small):初始化车位有几个
2.bool addCar(int carType):carType类型的车可以停进去的话返回true。
Example 1:
Input
["ParkingSystem", "addCar", "addCar", "addCar", "addCar"]
[[1, 1, 0], [1], [2], [3], [1]]
Output
[null, true, true, false, false]
Explanation
ParkingSystem parkingSystem = new ParkingSystem(1, 1, 0);
parkingSystem.addCar(1); // return true because there is 1 available slot for
a big car
parkingSystem.addCar(2); // return true because there is 1 available slot for
a medium car
parkingSystem.addCar(3); // return false because there is no available slot
for a small car
parkingSystem.addCar(1); // return false because there is no available slot
for a big car. It is already occupied.
思路:
1.用一个阵列保存当前车位剩几个
Java Code
作者: a9486l (a9486l)   2022-05-29 20:46:00
大师

Links booklink

Contact Us: admin [ a t ] ucptt.com