diff --git a/JinHaLim/Easy/solution_1528.js b/JinHaLim/Easy/solution_1528.js new file mode 100644 index 0000000..8d10ec6 --- /dev/null +++ b/JinHaLim/Easy/solution_1528.js @@ -0,0 +1,17 @@ +/** + * @param {string} s + * @param {number[]} indices + * @return {string} + */ +var restoreString = function(s, indices) { + let map = new Map(); + let string = ''; + s.split('').forEach((v,i) => { + map.set(indices[i],v); + }); + for (let i = 0; i < map.size; i++) { + string += map.get(i); + } + return string; +}; +console.log(restoreString("codeleet",[4,5,6,7,0,2,1,3])) \ No newline at end of file diff --git a/JinHaLim/Easy/solution_1603.js b/JinHaLim/Easy/solution_1603.js new file mode 100644 index 0000000..b49675b --- /dev/null +++ b/JinHaLim/Easy/solution_1603.js @@ -0,0 +1,48 @@ +/** + * @param {number} big + * @param {number} medium + * @param {number} small + */ +var ParkingSystem = function(big, medium, small) { + this.big = big; + this.medium = medium; + this.small = small; + return this; +}; + +/** + * @param {number} carType + * @return {boolean} + */ +ParkingSystem.prototype.addCar = function(carType) { + switch (carType) { + case 1: //큰 + if (this.big > 0) { + this.big -= 1; + return true; + } + break; + case 2: //중간 + if (this.medium > 0) { + this.medium -= 1; + return true; + } + break; + case 3: //작은 + if (this.small > 0) { + this.small -= 1; + return true; + } + break; + default: + break; + } + return false; +}; + +/** + * Your ParkingSystem object will be instantiated and called as such: + * var obj = new ParkingSystem(big, medium, small) + * var param_1 = obj.addCar(carType) + */ +console.log(new ParkingSystem(1,1,0)) diff --git a/JinHaLim/Easy/solution_771.js b/JinHaLim/Easy/solution_771.js new file mode 100644 index 0000000..aa45cf8 --- /dev/null +++ b/JinHaLim/Easy/solution_771.js @@ -0,0 +1,15 @@ +/** + * @param {string} jewels + * @param {string} stones + * @return {number} + */ +var numJewelsInStones = function(jewels, stones) { + const jewelArr = jewels.split(''); + return stones.split('').reduce((acc,curr) => { + if (jewelArr.includes(curr)) { + acc += 1; + } + return acc; + },0); +}; +console.log(numJewelsInStones("aA","aAAbbbb")); \ No newline at end of file