1. Code
class ParkingSystem:
def __init__(self, big: int, medium: int, small: int):
self.options = [big, medium, small]
def addCar(self, carType: int) -> bool:
# inputs are 1 or 2 or 3
if self.options[carType-1] > 0:
self.options[carType-1] -= 1
return True
else:
return False
2. Result
Runtime : 128 ms(96.48%), Memory usage : 14.8 MB(11.14%)
(Runtime can be different by a system even if it is a same code.)