1708. Design Parking System
My accepted Python solution to LeetCode problem 1708, Design Parking System, running in 3ms.
- Difficulty: Easy
- Python
- Runtime 3ms
- Memory 17.7MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 3ms, memory 17.7MB, accepted 2025-12-29.
class ParkingSystem:
# Time: O(1) for both init and addCar
# Space: O(1)
def __init__(self, big: int, medium: int, small: int):
self.slots = [0, big, medium, small]
def addCar(self, carType: int) -> bool:
if self.slots[carType] > 0:
self.slots[carType] -= 1
return True
return False
# Your ParkingSystem object will be instantiated and called as such:
# obj = ParkingSystem(big, medium, small)
# param_1 = obj.addCar(carType)