Skip to content

Commit 9c9d7a1

Browse files
add 1603
1 parent a49e1d1 commit 9c9d7a1

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1603|[Design Parking System](https://leetcode.com/problems/design-parking-system/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1603.java) ||Easy|Design|
1112
|1601|[Maximum Number of Achievable Transfer Requests](https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1601.java) ||Hard|Backtracking|
1213
|1598|[Crawler Log Folder](https://leetcode.com/problems/crawler-log-folder/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1598.java) ||Easy|Stack|
1314
|1592|[Rearrange Spaces Between Words](https://leetcode.com/problems/rearrange-spaces-between-words/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1592.java) ||Easy|String|
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _1603 {
4+
public static class Solution1 {
5+
class ParkingSystem {
6+
int[] slots = new int[3];
7+
8+
public ParkingSystem(int big, int medium, int small) {
9+
slots[0] = big;
10+
slots[1] = medium;
11+
slots[2] = small;
12+
}
13+
14+
public boolean addCar(int carType) {
15+
if (carType == 1) {
16+
if (slots[0] > 0) {
17+
slots[0]--;
18+
return true;
19+
} else {
20+
return false;
21+
}
22+
} else if (carType == 2) {
23+
if (slots[1] > 0) {
24+
slots[1]--;
25+
return true;
26+
} else {
27+
return false;
28+
}
29+
} else {
30+
if (slots[2] > 0) {
31+
slots[2]--;
32+
return true;
33+
} else {
34+
return false;
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)