Easy C/C++/Python3 solutions using array/unordered_map/initializer list
Intuition\n Describe your first thoughts on how to solve this problem. \nStandard OOP problem!\n# Approach\n Describe your approach to solving the problem. \n\n
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nStandard OOP problem!\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code using unordered_map\n```\nclass ParkingSystem {\npublic:\n    unordered_map<int, int> cars;\n    ParkingSystem(int big, int medium, int small) {\n        cars[1]=big;\n        cars[2]=medium;\n        cars[3]=small;\n    }\n    \n    bool addCar(int carType) {\n        if (cars[carType]==0) return 0;\n        else{\n            cars[carType]--;\n            return 1;\n        }\n    }\n};\n\n/**\n * Your ParkingSystem object will be instantiated and called as such:\n * ParkingSystem* obj = new ParkingSystem(big, medium, small);\n * bool param_1 = obj->addCar(carType);\n */\n```\n# 2nd solution using C++ initializer list for constructor\n```\nclass ParkingSystem {\npublic:\n    int big, medium, small;\n    ParkingSystem(int big, int medium, int small) :big(big), medium(medium),\n     small(small) {\n        \n    }\n    \n    bool addCar(int carType) {\n        switch(carType){\n            case 1: if (big==0) return 0;\n                    else{\n                        big--;\n                        return 1;\n                    }\n            break;\n            \n            case 2: if (medium==0) return 0;\n                    else{\n                        medium--;\n                        return 1;\n                    }\n            break;\n\n            case 3:if (small==0) return 0;\n                    else{\n                        small--;\n                        return 1;\n                    } \n            break;\n        }\n        return 0;\n    }\n};\n\n/**\n * Your ParkingSystem object will be instantiated and called as such:\n * ParkingSystem* obj = new ParkingSystem(big, medium, small);\n * bool param_1 = obj->addCar(carType);\n */\n```\n# 3rd solution\n```\nclass ParkingSystem {\npublic:\n    int cars[3];\n    ParkingSystem(int big, int medium, int small) {\n        cars[1]=big;\n        cars[2]=medium;\n        cars[0]=small;\n    }\n    \n    bool addCar(int carType) {\n        if (cars[carType%3]==0) return 0;\n        else{\n            cars[carType%3]--;\n            return 1;\n        }\n    }\n};\n\n/**\n * Your ParkingSystem object will be instantiated and called as such:\n * ParkingSystem* obj = new ParkingSystem(big, medium, small);\n * bool param_1 = obj->addCar(carType);\n */\n```\n#  Python solution\n```\nclass ParkingSystem:\n\n    def __init__(self, big: int, medium: int, small: int):\n        self.cars=[small, big, medium]\n\n    def addCar(self, carType: int) -> bool:\n        if self.cars[carType%3]==0: \n            return False\n        else:\n            self.cars[carType%3]-=1\n            return True\n```\n# C solution\n```\ntypedef struct {\n    int cars[3];\n    \n} ParkingSystem;\n\n\nParkingSystem* parkingSystemCreate(int big, int medium, int small) {\n    ParkingSystem* obj=(ParkingSystem*)malloc(sizeof(ParkingSystem));\n    obj->cars[1]=big;\n    obj->cars[2]=medium;\n    obj->cars[0]=small;\n    return obj;\n}\n\nbool parkingSystemAddCar(ParkingSystem* obj, int carType) {\n    if (obj->cars[carType%3]==0) return 0;\n        else{\n            obj->cars[carType%3]--;\n            return 1;\n        }\n  \n}\n\nvoid parkingSystemFree(ParkingSystem* obj) {\n    free(obj);\n}\n\n/**\n * Your ParkingSystem struct will be instantiated and called as such:\n * ParkingSystem* obj = parkingSystemCreate(big, medium, small);\n * bool param_1 = parkingSystemAddCar(obj, carType);\n \n * parkingSystemFree(obj);\n*/\n```\n\n
['Hash Table', 'Design', 'Simulation', 'Counting', 'C++']