π‘ λ¬Έμ
π― νμ΄ κ³Όμ
3μ’
μ μ°¨λ (big, medium, small
) μ μμ©νλ μ£Όμ°¨μ₯ μμ€ν
μ ꡬννλ λ¬Έμ μ
λλ€.
carType
μΈλ±μ±μ νΈνκΈ° νκΈ° μν΄ λ°°μ΄μ ν¬κΈ°λ₯Ό νλ λλ €μ μ¬μ©ν©λλ€.
π¨π» μ½λ
/**
* @param {number} big
* @param {number} medium
* @param {number} small
*/
var ParkingSystem = function(big, medium, small) {
this.parkingSlots = [0, big, medium, small]
};
/**
* @param {number} carType
* @return {boolean}
*/
ParkingSystem.prototype.addCar = function(carType) {
if (this.parkingSlots[carType]) {
this.parkingSlots[carType] -= 1
return true
}
return false
};
λ°μν
'π algorithm > leetcode' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
LeetCode 238 - Product of Array Except Self (Medium) (2) | 2023.04.24 |
---|---|
LeetCode 2390 - Removing Stars From a String (Medium) (0) | 2023.04.24 |
LeetCode 15 - 3Sum (Medium) (0) | 2023.04.24 |
LeetCode 13 - Roman to Integer (Easy) (0) | 2023.04.24 |
LeetCode 994 - Rotting Oranges (Medium) (0) | 2023.04.24 |
π¬ λκΈ