Skip to content

Commit 44cf9b8

Browse files
Merge pull request #2694 from leahjia/1603-design-parking-system
1603-design-parking-system.java
2 parents 3b14870 + e43518b commit 44cf9b8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

java/1603-design-parking-system.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class ParkingSystem {
2+
3+
int[] space;
4+
5+
public ParkingSystem(int big, int medium, int small) {
6+
this.space = new int[] { big, medium, small };
7+
}
8+
9+
public boolean addCar(int carType) {
10+
if (this.space[carType - 1] == 0) {
11+
return false;
12+
}
13+
this.space[carType - 1]--;
14+
return true;
15+
}
16+
}

0 commit comments

Comments
 (0)