Horje
1603. Design Parking System leetcode solution in c++ Code Example
1603. Design Parking System leetcode solution in c++
class ParkingSystem {
public:
    ParkingSystem(int big, int medium, int small) {
        this->big = big;
        this->medium = medium;
        this->small = small;
    }
    
    bool addCar(int carType) {
        if(carType == 1 && big > 0)
        {
            big--;
            return true;
        }else if(carType == 2 && medium > 0)
        {
            medium--;
            return true;
        }else if(carType == 3 && small > 0)
        {
            small--;
            return true;
        }
        return false;
    }
private:
  int big;
  int medium;
  int small;  
};

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




Cpp

Related
getline int Code Example getline int Code Example
define a type in c++ Code Example define a type in c++ Code Example
input in c++ Code Example input in c++ Code Example
how to get the first element of a map in c++ Code Example how to get the first element of a map in c++ Code Example
why is my unity crashing Code Example why is my unity crashing Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8