카펫

function solution(brown = 10, yellow = 2) {
let answer = [0, 0];
let result = brown + yellow;
for (let index = 1; index < result; index++) {
for (let i = 3; i < result; i++) {
if (
index * i === result &&
index >= i &&
(index - 2) * (i - 2) === yellow
) {
answer[0] = index;
answer[1] = i;
return answer;
}
}
}
return answer;
}
점프와 순간이동

function solution(n) {
let ans = 1;
while (n !== 1) {
if (Number.isInteger(n / 2)) {
n /= 2;
} else {
--n;
++ans;
}
}
return ans;
}
구명보트

function solution(people = [70, 80, 50], limit = 100) {
let answer = 0;
let i = 0;
let j = people.length - 1;
people.sort((a, b) => a - b);
while (i <= j) {
if (people[i] + people[j] <= limit) {
i++;
j--;
} else {
j--;
}
++answer;
}
return answer;
}