Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ca9adc2

Browse files
authored
feat: add C# solution to lc problem: No.1603 (doocs#1661)
No.1603.Design Parking System
1 parent cadd62f commit ca9adc2

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

‎solution/1600-1699/1603.Design Parking System/README.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,33 @@ void parkingSystemFree(ParkingSystem* obj) {
257257
*/
258258
```
259259
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+
260287
### **...**
261288

262289
```

‎solution/1600-1699/1603.Design Parking System/README_EN.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,34 @@ void parkingSystemFree(ParkingSystem* obj) {
241241
*/
242242
```
243243
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+
244272
### **...**
245273

246274
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /