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
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- ์นด์นด์ค ์ฝํ
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- ์ค์ฝํ
- emtion app router
- ์ฌ์ฉ์ฑ ๊ฐ์
- app router emotion
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ์ต์ ๋์ฒด์ด๋
- js ์ค์ฝํ
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- suspense react-query
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- next13 emotion
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- suspense ๋์์๋ฆฌ
- suspense ๋น๋๊ธฐ
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- ๋ฐฑ์ค 1339๋ฒ js
- ๊ตฌ๋ฆํค
- emotion RSC
- suspense ๋ณ๋ชฉํ์
- ๋ฐฑ์ค 2108 nodejs
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- js
- js ๋ฌธ์์ด ์์ถ
Archives
- Today
- Total
Lennon FE
[ํ๋ก๊ทธ๋๋จธ์ค] ์ํด๋ฆฌ์ฑ๋ฆฐ์ง 12์ฃผ์ฐจ (js) ๋ณธ๋ฌธ
๐ฅ Algorithm/Programmers
[ํ๋ก๊ทธ๋๋จธ์ค] ์ํด๋ฆฌ์ฑ๋ฆฐ์ง 12์ฃผ์ฐจ (js)
Lennon 2021. 10. 26. 22:02728x90
๋ฐ์ํ
https://programmers.co.kr/learn/courses/30/lessons/87946?language=javascript
function solution(k, dungeons) {
let answer = 0;
let permutationDungeons = permutation(dungeons, dungeons.length);
permutationDungeons = permutationDungeons.map((v) => v.split(" ").map((vi) => vi.split(",")));
for(let i = 0; i < permutationDungeons.length; i++){
let fatigue = k;
let count = 0;
for(let j = 0; j < permutationDungeons[i].length; j++){
if(fatigue >= permutationDungeons[i][j][0]){
fatigue -= permutationDungeons[i][j][1];
count++;
}
if(fatigue < 0){
break;
}
}
answer = Math.max(count, answer);
}
return answer;
}
function permutation(arr, selectNum){
let result = [];
if(selectNum === 1) return arr.filter((v)=> [v]);
arr.forEach((v,idx,arr)=>{
const fixer = v;
const restArr = arr.filter((val, index)=> index !== idx);
const permuArr = permutation(restArr, selectNum-1);
const combineFixer = permuArr.map((v)=> fixer + " " + v);
result.push(...combineFixer);
})
return result;
}
๋ฌธ์ ์ ๋์ ์ ์ต๋ ๊ธธ์ด๋ 8์ด๋ผ ๋ช ์๋์ด ์์ด ์์ ํ์์ ์ด์ฉํด ์ฝ๊ฒ ํ ์ ์์๋ค.
dfs๋ฅผ ์ด์ฉํ ํ์ด๋ณด๋ค ํจ์จ์ฑ์ ๋จ์ด์ก๋ค ใ ใ ใ
๋ค์์ dfs๊ฐ ์ต์ํด์ง๋ฉด ์ด์ฉํด ํ์ด๋ด์ผ๊ฒ ๋ค.
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฐฉ๊ธ ๊ทธ๊ณก (js) (0) | 2021.10.28 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] (1์ฐจ) ๋ด์ค ํด๋ฌ์คํฐ๋ง (js) (0) | 2021.10.27 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฒ ์คํธ์จ๋ฒ (js) (0) | 2021.10.26 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๊ฐ์ฅ ํฐ ์ (js) (0) | 2021.10.25 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๊ธฐ๋ฅ ๊ฐ๋ฐ (js) (0) | 2021.10.25 |
Comments