LeetCode 1603. 设计停车系统

题目链接

1603. 设计停车系统

class ParkingSystem {
    
    
public:
    vector<int> tot;
    ParkingSystem(int big, int medium, int small) {
    
    
        tot = {
    
    big, medium, small};
    }
    
    bool addCar(int carType) {
    
    
        carType--;
        if(tot[carType] >= 1){
    
    
            tot[carType]--;
            return true;
        }
        return false;
    }
};

/**
 * Your ParkingSystem object will be instantiated and called as such:
 * ParkingSystem* obj = new ParkingSystem(big, medium, small);
 * bool param_1 = obj->addCar(carType);
 */

猜你喜欢

转载自blog.csdn.net/zy440458/article/details/115003407