Elegant Python3 Solution || Beats 93.08% Submissions 🚀
IntuitionThe problem involves managing a parking lot with limited spaces for three types of cars: big, medium, and small. The idea is straightforward: track the
[![image.png](https://assets.leetcode.com/users/images/c4a45ace-1824-4ce6-b7f8-bccbf51c7ba8_1734888423.7034686.png)](https://leetcode.com/problems/design-parking-system/submissions/1485636852/)
# Intuition
The problem involves managing a parking lot with limited spaces for three types of cars: big, medium, and small. The idea is straightforward: track the available slots for each car type and decrement the count when a car of that type is parked. If there are no available slots for a specific car type, parking fails. This can be efficiently solved with an array to store the number of available slots for each car type.

# Approach
1. **Initialization**:
   - Use a list `slots` to store the number of available slots for each car type. Index `0` corresponds to big cars, `1` to medium cars, and `2` to small cars.

2. **Parking Logic**:
   - When a car arrives, check if there is an available slot for the car type (`carType - 1` to align with zero-based indexing).
   - If there is a slot, decrement the count for that type and return `True`.
   - If no slots are available, return `False`.

This approach ensures constant time complexity for each parking operation.

# Complexity
- **Time complexity**:  
  $$O(1)$$  
  Each call to `addCar` involves a single index access and a comparison, both of which are constant-time operations.

- **Space complexity**:  
  $$O(1)$$  
  Only a fixed-size list (of three elements) is used to track the slots, regardless of the number of operations.

# Code
```python
class ParkingSystem:
    def __init__(self, big, medium, small):
        # Initialize slots for big, medium, and small cars
        self.slots = [big, medium, small]

    def addCar(self, carType):
        # Check if there are available slots for the car type
        self.slots[carType - 1] -= 1
        return self.slots[carType - 1] >= 0


# Your ParkingSystem object will be instantiated and called as such:
# obj = ParkingSystem(big, medium, small)
# param_1 = obj.addCar(carType)
```

This solution is simple, efficient, and meets the problem's requirements while ensuring optimal performance for all operations.
['Python3']