+ ์์ ํ์ ๋ฌธ์
1. ๋ฌธ์ :https://school.programmers.co.kr/learn/courses/30/lessons/87946
2. ํ์ด
๋ฐฐ์ด 123,231 ๋ฑ์ผ๋ก ๋๋ ๋ฒ ์์๋ฌ์ผ๊ฒ ๋ค!
3. ์ฝ๋
class Solution {
static boolean[] visited;
static int count = 0;
public int solution(int k, int[][] dungeons) {
visited = new boolean[dungeons.length];
dfs(0, k, dungeons);
return count;
}
private void dfs(int depth, int fatigue, int[][] dungeons){
for (int i = 0; i < dungeons.length; i++){
if (visited[i] || dungeons[i][0] > fatigue) {
continue;
}
visited[i] = true;
dfs(depth + 1, fatigue - dungeons[i][1], dungeons);
visited[i] = false;
}
count = Math.max(count, depth);
}
}
'๐ป Coding Problems Solving > DFS | BFS | Backtracking' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ๊ฒ์ ๋งต ์ต๋จ๊ฑฐ๋ฆฌ(java) (0) | 2023.03.31 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ํ๋ ์ฆ4๋ธ๋ก (0) | 2023.03.13 |
[BOJ 1303] ์ ์-์ ํฌ (0) | 2022.07.04 |
[BOJ 1260] DFS์ BFS (0) | 2022.07.01 |
[BOJ 17070] ํ์ดํ ์ฎ๊ธฐ๊ธฐ1 (java) (0) | 2022.07.01 |
์ต๊ทผ๋๊ธ