forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_1603.java
40 lines (37 loc) · 1.13 KB
/
_1603.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
package com.fishercoder.solutions;
public class _1603 {
public static class Solution1 {
class ParkingSystem {
int[] slots = new int[3];
public ParkingSystem(int big, int medium, int small) {
slots[0] = big;
slots[1] = medium;
slots[2] = small;
}
public boolean addCar(int carType) {
if (carType == 1) {
if (slots[0] > 0) {
slots[0]--;
return true;
} else {
return false;
}
} else if (carType == 2) {
if (slots[1] > 0) {
slots[1]--;
return true;
} else {
return false;
}
} else {
if (slots[2] > 0) {
slots[2]--;
return true;
} else {
return false;
}
}
}
}
}
}