We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6c7a98c commit 877ffe9Copy full SHA for 877ffe9
1 file changed
c++/leetcode/designparkingsystem.cpp
@@ -0,0 +1,32 @@
1
+class ParkingSystem {
2
+public:
3
+ int big;
4
+ int medium;
5
+ int small;
6
+
7
+ ParkingSystem(int big, int medium, int small) {
8
+ this->big = big;
9
+ this->medium = medium;
10
+ this->small = small;
11
+ }
12
13
+ bool addCar(int carType) {
14
15
+ if(carType == 1 && big == 0 || carType == 2 && medium == 0 || carType == 3 && small == 0)
16
+ return false;
17
18
+ if(carType == 1) big--;
19
+ if(carType == 2) medium--;
20
+ if(carType == 3) small--;
21
22
+ return true;
23
24
+};
25
26
+/**
27
+ * Your ParkingSystem object will be instantiated and called as such:
28
+ * ParkingSystem* obj = new ParkingSystem(big, medium, small);
29
+ * bool param_1 = obj->addCar(carType);
30
31
+ O(1)
32
+ */
0 commit comments