Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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);
 */
Comment

PREVIOUS NEXT
Code Example
Cpp :: frac{2}{5}MR^2 typed in c++ 
Cpp :: is there anything like vector<intx[100] 
Cpp :: how can I convert each and every element of string push into set in c++? 
Cpp :: Chef and Races codechef solution in c++ 
Cpp :: sort sub vector, sort range of vector c++ 
Cpp :: e.cpp 
Cpp :: 496. Next Greater Element I.cpp 
Cpp :: error when using template base class members 
Cpp :: c++ server service ros 
Cpp :: irremoteesp8266 example 
Cpp :: bullet physics directx 11 
Cpp :: min stack 
Cpp :: while loop in c++ 
Cpp :: c++ array on heap 
Cpp :: c++ split string by sstream 
Cpp :: array list cpp 
Cpp :: https://www.codegrepper.com 
Cpp :: vector erase iterator 
Cpp :: english to french typing online 
C :: malloc is undefined 
C :: arduino wifi ip address to string 
C :: c random list 
C :: how to print helloq world in c 
C :: how to convert string to integer in c 
C :: for loop c 
C :: 0/1 knapsack problem in c 
C :: c define array size 
C :: why do we need return 0 in c? 
C :: how to represent unsigned char with % c 
C :: read a document in c getting name from console 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =