1603. 设计停车系统
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/design-parking-system
代码如下:
class ParkingSystem(object):
def __init__(self, big, medium, small):
"""
:type big: int
:type medium: int
:type small: int
"""
self.big = big
self.medium = medium
self.small = small
def addCar(self, carType):
"""
:type carType: int
:rtype: bool
"""
if carType == 1:
self.big -= 1
if self.big >= 0:
return True
else:
return False
if carType == 2:
self.medium -= 1
if self.medium >= 0:
return True
else:
return False
if carType == 3:
self.small -= 1
if self.small >= 0:
return True
else:
return False
提交结果图: