File tree 3 files changed +77
-0
lines changed
solution/1600-1699/1603.Design Parking System
3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,33 @@ void parkingSystemFree(ParkingSystem* obj) {
257
257
* /
258
258
```
259
259
260
+ ### **C#**
261
+
262
+ ```cs
263
+ public class ParkingSystem {
264
+
265
+ private List<int> cnt;
266
+
267
+ public ParkingSystem(int big, int medium, int small) {
268
+ cnt = new List<int>() {0 , big, medium, small};
269
+ }
270
+
271
+ public bool AddCar(int carType) {
272
+ if (cnt[carType] == 0) {
273
+ return false;
274
+ }
275
+ --cnt[carType];
276
+ return true;
277
+ }
278
+ }
279
+
280
+ /**
281
+ * Your ParkingSystem object will be instantiated and called as such:
282
+ * ParkingSystem obj = new ParkingSystem(big, medium, small);
283
+ * bool param_1 = obj.AddCar(carType);
284
+ */
285
+ ```
286
+
260
287
### ** ...**
261
288
262
289
```
Original file line number Diff line number Diff line change @@ -241,6 +241,34 @@ void parkingSystemFree(ParkingSystem* obj) {
241
241
* /
242
242
```
243
243
244
+ ### **C#**
245
+
246
+ ```cs
247
+ public class ParkingSystem {
248
+
249
+ private List<int> cnt;
250
+
251
+ public ParkingSystem(int big, int medium, int small) {
252
+ cnt = new List<int>() {0 , big, medium, small};
253
+ }
254
+
255
+ public bool AddCar(int carType) {
256
+ if (cnt[carType] == 0) {
257
+ return false;
258
+ }
259
+ --cnt[carType];
260
+ return true;
261
+ }
262
+ }
263
+
264
+ /**
265
+ * Your ParkingSystem object will be instantiated and called as such:
266
+ * ParkingSystem obj = new ParkingSystem(big, medium, small);
267
+ * bool param_1 = obj.AddCar(carType);
268
+ */
269
+ ```
270
+
271
+
244
272
### ** ...**
245
273
246
274
```
Original file line number Diff line number Diff line change
1
+ public class ParkingSystem {
2
+
3
+ private List < int > cnt ;
4
+
5
+ public ParkingSystem ( int big , int medium , int small ) {
6
+ cnt = new List < int > ( ) { 0 , big , medium , small } ;
7
+ }
8
+
9
+ public bool AddCar ( int carType ) {
10
+ if ( cnt [ carType ] == 0 ) {
11
+ return false ;
12
+ }
13
+ -- cnt [ carType ] ;
14
+ return true ;
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Your ParkingSystem object will be instantiated and called as such:
20
+ * ParkingSystem obj = new ParkingSystem(big, medium, small);
21
+ * bool param_1 = obj.AddCar(carType);
22
+ */
You can’t perform that action at this time.
0 commit comments