Design Parking System LeetCode solution in Java

1
class ParkingSystem {
2
private int slots[] = new int[3];
3

4
public ParkingSystem(int big, int medium, int small) {
5
slots[0] = big;
6
slots[1] = medium;
7
slots[2] = small;
8
}
9

10
public boolean addCar(int carType) {
11
if (slots[carType - 1] > 0) {
12
slots[carType - 1]--;
13
return true;
14
}
15
return false;
16
}
17
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0