public class ParkingSystem {
Dictionary<int, int> _parkSlots = new Dictionary<int, int>();
public ParkingSystem(int big, int medium, int small) {
_parkSlots[1] = big;
_parkSlots[2] = medium;
_parkSlots[3] = small;
}
public bool AddCar(int carType) {
if (_parkSlots[carType] > 0) {
--_parkSlots[carType];
return true;
}
return false;
}
}
"Simplicity can't be bought later, it must be earned from the start" -- DB
Sunday, February 14, 2021
Leetcode Everyday: 1603. Design Parking System. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment