
๐ก ๋ฌธ์
๐ฏ ํ์ด ๊ณผ์
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 |
๐ฌ ๋๊ธ