-
Notifications
You must be signed in to change notification settings - Fork 0
/
DesignParkingSystem.java
54 lines (43 loc) · 1.04 KB
/
DesignParkingSystem.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package misc;
import utils.LeetCode;
import utils.Level;
@LeetCode(no=1603,
title = " Design Parking System",
url = "https://leetcode.com/problems/design-parking-system/",
level = Level.EASY)
public class DesignParkingSystem {
}
class ParkingSystem {
private int big;
private int medium;
private int small;
public ParkingSystem(int big, int medium, int small) {
this.big=big;
this.medium=medium;
this.small=small;
}
public boolean addCar(int carType) {
boolean added=false;
switch(carType){
case 1:
if(big>0){
big-=1;
added=true;
}
break;
case 2:
if(medium>0){
medium-=1;
added=true;
}
break;
case 3:
if(small>0){
small-=1;
added=true;
}
break;
}
return added;
}
}