1603. Design Parking System
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 87% Topics: Design, Simulation, Counting
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(1)
# Space: O(1)
class ParkingSystem(object):
def __init__(self, big, medium, small):
"""
:type big: int
:type medium: int
:type small: int
"""
self.__space = [0, big, medium, small]
def addCar(self, carType):
"""
:type carType: int
:rtype: bool
"""
if self.__space[carType] > 0:
self.__space[carType] -= 1
return True
return False
Solution from kamyu104/LeetCode-Solutions · MIT