1603. 设计停车系统 第 36 场双周赛

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

猜你喜欢

转载自blog.csdn.net/qq_40092110/article/details/108944170