1603. 设计停车系统 第 36 场双周赛
传送门
题意
结题思路
# 思路1:
# python的语法,成员变量之类的。
# __init__会给python类初始化,第一个参数为self,self则相当于c++的静态成员函数。
class ParkingSystem(object):
def __init__(self, big, medium, small):
"""
:type big: int
:type medium: int
:type small: int
"""
self.data = [0, big, medium, small]
def addCar(self, carType):
"""
:type carType: int
:rtype: bool
"""
if self.data[carType] <= 0:
return False
self.data[carType] -= 1
return True