From 9075ad82961a2ae5e7a940af07b0341be4eb1721 Mon Sep 17 00:00:00 2001 From: TassaraR Date: Sat, 5 Aug 2023 19:21:43 -0400 Subject: [PATCH] Added 1603 - design parking system Python solution --- python/1603-design-parking-system.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 python/1603-design-parking-system.py diff --git a/python/1603-design-parking-system.py b/python/1603-design-parking-system.py new file mode 100644 index 000000000..498d32e01 --- /dev/null +++ b/python/1603-design-parking-system.py @@ -0,0 +1,17 @@ +class ParkingSystem: + + def __init__(self, big: int, medium: int, small: int): + + # [total_occupied, max_capacity] + self.parking = { + 1: [0 ,big], + 2: [0, medium], + 3: [0, small] + } + + def addCar(self, carType: int) -> bool: + new_total = self.parking[carType][0] + 1 + if new_total <= self.parking[carType][1]: + self.parking[carType][0] += 1 + return True + return False