Notice
Recent Posts
Recent Comments
Link
μΌ | μ | ν | μ | λͺ© | κΈ | ν |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- λ°±μ€ 1339λ² nodejs
- μ€μ½ν
- suspense λ³λͺ©νμ
- λ°±μ€ 1339λ² js
- λ°±μ€ 1339λ² μλ°μ€ν¬λ¦½νΈ
- μ¬μ©μ± κ°μ
- 리μ‘νΈμΏΌλ¦¬ suspense
- js 거리λκΈ° νμΈνκΈ°
- λ°±μ€ 2108 nodejs
- λ°±μ€ 2108 μλ°μ€ν¬λ¦½νΈ
- js
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- μλ°μ€ν¬λ¦½νΈ μ€μ½ν
- js μ€μ½ν
- suspense react-query
- νλ‘κ·Έλλ¨Έμ€ λ¬Έμμ΄ μμΆ
- app router emotion
- νλ‘κ·Έλλ¨Έμ€ κ±°λ¦¬λκΈ° νμΈνκΈ°
- ꡬλ¦ν€ μ±λ¦°μ§
- μλ°μ€ν¬λ¦½νΈ λ¬Έμμ΄ μμΆ
- suspense λμμ리
- next13 emotion
- ꡬλ¦ν€ μ±λ¦°μ§ νκ³
- suspense λΉλκΈ°
- emotion RSC
- μΉ΄μΉ΄μ€ μ½ν
- emtion app router
- μ΅μ λ체μ΄λ
- js λ¬Έμμ΄ μμΆ
- ꡬλ¦ν€
Archives
- Today
- Total
Lennon FE
[νλ‘κ·Έλλ¨Έμ€] νΌλ‘λ - μλ°μ€ν¬λ¦½νΈ(js) λ³Έλ¬Έ
π₯ Algorithm/Programmers
[νλ‘κ·Έλλ¨Έμ€] νΌλ‘λ - μλ°μ€ν¬λ¦½νΈ(js)
Lennon 2022. 3. 14. 17:40728x90
λ°μν
https://programmers.co.kr/learn/courses/30/lessons/87946?language=javascript
function solution(k, dungeons) {
const result = getPermutations(dungeons, dungeons.length);
let maxDungeon = 0;
result.forEach((v) => {
let fatigue = k;
let count = 0;
for (let i = 0; i < v.length; i++) {
if (fatigue >= v[i][0]) {
count++;
fatigue -= v[i][1];
} else {
break;
}
}
maxDungeon = Math.max(maxDungeon, count);
});
return maxDungeon;
}
const getPermutations = function (arr, selectNumber) {
const results = [];
if (selectNumber === 1) return arr.map((el) => [el]);
arr.forEach((fixed, index, origin) => {
const rest = [...origin.slice(0, index), ...origin.slice(index + 1)];
const permutations = getPermutations(rest, selectNumber - 1);
const attached = permutations.map((el) => [fixed, ...el]);
results.push(...attached);
});
return results;
};
DPλ¬Έμ μΈκ° μΆμμ§λ§ DPλ‘ ν΄κ²°μ΄ μλ κ² κ°μκ³ , DFSλ‘ νμ΄λ λμ§λ§,
μ΅λ λμ μκ° 8μΈ κ±Έ 보μ μμ νμμΌλ‘ νμ΄λ μκ΄μμ κ² κ°μ μμ νμμΌλ‘ νμλ€.
λͺ¨λ μμλ₯Ό ꡬν ν μμ°¨μ μΌλ‘ λ리면 λ!
728x90
λ°μν
'π₯ Algorithm > Programmers' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[νλ‘κ·Έλλ¨Έμ€ Lv.3] μ κ΅μ¬μ¬ (0) | 2022.03.01 |
---|---|
[νλ‘κ·Έλλ¨Έμ€] λ€λ¦¬λ₯Ό μ§λλ νΈλ (js) (0) | 2022.02.10 |
[νλ‘κ·Έλλ¨Έμ€ Lv.3] μ΄μ€μ°μ μμν (js) (0) | 2022.02.03 |
[νλ‘κ·Έλλ¨Έμ€ Lv.3] λΆλ μ¬μ©μ (js) (0) | 2022.02.03 |
[νλ‘κ·Έλλ¨Έμ€ Lv.3] λ¨μ μΉ΄λ©λΌ (js) (0) | 2022.01.30 |
Comments