Python🔥Java🔥C++🔥Simple Solution🔥Easy to Understand
!! BIG ANNOUNCEMENT !!\nI am currently Giving away my premium content well-structured assignments and study materials to clear interviews at top companies relat
**!! BIG ANNOUNCEMENT !!**\nI am currently Giving away my premium content well-structured assignments and study materials to clear interviews at top companies related to computer science and data science to my current Subscribers. This is only for first 10,000 Subscribers.  **DON\'T FORGET** to Subscribe\n\n# Search \uD83D\uDC49 `Tech Wired Leetcode` to Subscribe\n\n# Video Solution\n\n# Search \uD83D\uDC49 `Design Parking System By Tech Wired` \n\n# or\n\n# Click the Link in my Profile\n\n# Approach:\nThe approach for the "Design Parking System" problem is to maintain a data structure that keeps track of the number of available parking spots for each car type. In this case, we can use a list or an array to store the available spots for big, medium, and small cars.\n\nInitialize the parking system: In the constructor or initialization method, store the number of available spots for each car type in the data structure (list or array).\n\nAdd a car: In the addCar method, check if there is an available spot for the specified car type. If the number of available spots for that car type is greater than 0, decrement the count of available spots for that car type and return true to indicate a successful addition. Otherwise, return false to indicate that no parking spot is available for that car type.\n\n# Intuition:\nThe parking system is designed to keep track of available parking spots for different car types. By maintaining the count of available spots for each car type, we can efficiently check and manage the parking availability for incoming cars.\n\nWhen initializing the parking system, we store the initial count of available spots for each car type. This allows us to keep track of the available spots throughout the parking process.\n\nWhen adding a car, we check if there is an available spot for the specified car type. If so, we decrement the count of available spots for that car type and indicate a successful addition. Otherwise, we indicate that no parking spot is available for that car type.\n\n\n\n```Python []\nclass ParkingSystem:\n    def __init__(self, big: int, medium: int, small: int):\n        self.spots = [big, medium, small]\n\n    def addCar(self, carType: int) -> bool:\n        if self.spots[carType - 1] > 0:\n            self.spots[carType - 1] -= 1\n            return True\n        else:\n            return False\n\n```\n```Java []\nclass ParkingSystem {\n    private int[] spots;\n\n    public ParkingSystem(int big, int medium, int small) {\n        spots = new int[]{big, medium, small};\n    }\n\n    public boolean addCar(int carType) {\n        if (spots[carType - 1] > 0) {\n            spots[carType - 1]--;\n            return true;\n        } else {\n            return false;\n        }\n    }\n}\n\n```\n```C++ []\nclass ParkingSystem {\nprivate:\n    int spots[3];\n\npublic:\n    ParkingSystem(int big, int medium, int small) {\n        spots[0] = big;\n        spots[1] = medium;\n        spots[2] = small;\n    }\n\n    bool addCar(int carType) {\n        if (spots[carType - 1] > 0) {\n            spots[carType - 1]--;\n            return true;\n        } else {\n            return false;\n        }\n    }\n};\n\n```\n
['Design', 'C++', 'Java', 'Python3']