Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions JinHaLim/Easy/solution_1528.js
Original file line number Diff line number Diff line change
@@ -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]))
48 changes: 48 additions & 0 deletions JinHaLim/Easy/solution_1603.js
Original file line number Diff line number Diff line change
@@ -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))
15 changes: 15 additions & 0 deletions JinHaLim/Easy/solution_771.js
Original file line number Diff line number Diff line change
@@ -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"));