Java Solution With Easy Explanation ✅✅
Approach\nHere\'s an explanation of the code in a beginner-friendly manner:\n\n1. The code defines a class called ParkingSystem which represents a parking lot. 
# Approach\nHere\'s an explanation of the code in a beginner-friendly manner:\n\n1. The code defines a class called `ParkingSystem` which represents a parking lot. It has a constructor method that takes three parameters: `big`, `medium`, and `small`, representing the number of available parking spaces for different car sizes.\n\n2. Inside the constructor, an array called `space` is created with three elements. The values passed as arguments (`big`, `medium`, and `small`) are stored in the `space` array to keep track of the available parking spaces for each car size.\n\n3. The class also has a method called `addCar`, which is used to add a car to the parking lot. It takes an integer parameter called `carType` representing the type of car (1 for big, 2 for medium, and 3 for small).\n\n4. Inside the `addCar` method, it first checks if there are available parking spaces for the specified car type. It does this by comparing the value at the corresponding index in the `space` array (`space[carType - 1]`) with 0. If there are available spaces, the condition is true.\n\n5. If there are available spaces for the specified car type, it means the car can be parked. It then reduces the number of available spaces for that car type by 1, indicating that one space is now occupied.\n\n6. Finally, it returns `true` to indicate that the car has been successfully parked.\n\n7. If there are no available spaces for the specified car type (i.e., the condition in step 4 is false), it means the car cannot be parked. In this case, it returns `false` to indicate that the car was not parked.\n\nIn simpler terms, the code represents a parking lot with different-sized spaces for cars. The `ParkingSystem` class keeps track of available spaces for each car size. The `addCar` method is used to park a car by specifying its size. If there are available spaces for that size, it deducts one space and returns `true`. If there are no available spaces, it returns `false`.\n\n# Code\n```\nclass ParkingSystem {\n    private int[] space;\n\n    public ParkingSystem(int big, int medium, int small) {\n        space = new int[]{big, medium, small};\n    }\n\n    public boolean addCar(int carType) {\n        if (space[carType - 1] > 0) {\n            space[carType - 1]--;\n            return true;\n        } \n        else  return false; \n    }\n}\n```\n```\nPlease upvote if you like the solution.\nHappy Coding! \uD83D\uDE0A\n```\n\n
['Design', 'Simulation', 'Counting', 'Java']