设计停车系统
题目
lettcode-1603题
难度:简单
解题思路
每种车都有每种车所对应的一个车位,而且不能停到其他车的车位上面去,所以说我们需要三个变量将每种车的车位数量存起来。
然后在有新车进来时,判断车辆的类型,然后查找相应的停车位,如果有车位就返回一个true,相当于停车成功,然后该类型的车位减去一个,如果车位为0,则不允许停车,返回false
具体代码
1 | class ParkingSystem { |
lettcode-1603题
难度:简单
每种车都有每种车所对应的一个车位,而且不能停到其他车的车位上面去,所以说我们需要三个变量将每种车的车位数量存起来。
然后在有新车进来时,判断车辆的类型,然后查找相应的停车位,如果有车位就返回一个true,相当于停车成功,然后该类型的车位减去一个,如果车位为0,则不允许停车,返回false
1 | class ParkingSystem { |