JAVA | Using single array | Time: O(no of addCar call) | Constant space
\nclass ParkingSystem {\n    \n    int[] slot=new int[4];\n    \n    public ParkingSystem(int big, int medium, int small) {\n        slot[1]=big;\n        slot[
```\nclass ParkingSystem {\n    \n    int[] slot=new int[4];\n    \n    public ParkingSystem(int big, int medium, int small) {\n        slot[1]=big;\n        slot[2]=medium;\n        slot[3]=small;\n    }\n    \n    public boolean addCar(int carType) {\n        \n        if(slot[carType]==0){\n            return false;\n        }\n        \n        slot[carType]--;\n        return true;\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 * boolean param_1 = obj.addCar(carType);\n */\n```
[]