DFS
https://cote.inflearn.com/contest/10/problem/08-01
https://and-some.tistory.com/647
https://cote.inflearn.com/contest/10/problem/08-02
https://and-some.tistory.com/648
https://cote.inflearn.com/contest/10/problem/08-03
https://and-some.tistory.com/649
https://cote.inflearn.com/contest/10/problem/08-05
https://and-some.tistory.com/651
#순열 공식
static int[] pm, ch, arr;
// pm: 결과 배열, ch : 중복 체크 배열, arr : 값 배열
public void DFS(int L) {
// 3 2-> 3 6 9 -> 3 6, 3 9, 6 3, 6 9, 9 3, 9 6
if (L == m) {
// 한 개의 순열 완성
for (int x : pm) {
System.out.print(x + " ");
}
System.out.println();
} else {
for (int i = 0; i < n; i++) {
if (ch[i] == 0) {
// 중복체크 하면서 값 배열에서 가져오기
ch[i] = 1;
// 사용하기 전 체크리스트에 1로 변경
pm[L] = arr[i];
// 값 배열에서 가져와 결과 배열에 넣기
DFS(L + 1);
// 기준 값 다음 값 가져오기
ch[i] = 0;
// 사용 후 체크리스트 0으로 초기화
}
}
}
}
https://and-some.tistory.com/652
https://cote.inflearn.com/contest/10/problem/08-07
https://and-some.tistory.com/653
https://cote.inflearn.com/contest/10/problem/08-08
https://and-some.tistory.com/654
BFS
https://cote.inflearn.com/contest/10/problem/07-08
https://and-some.tistory.com/644
https://cote.inflearn.com/contest/10/problem/08-11
https://and-some.tistory.com/646
https://cote.inflearn.com/contest/10/problem/08-12
https://and-some.tistory.com/656
DFS/BFS
https://cote.inflearn.com/contest/10/problem/08-13
https://and-some.tistory.com/657
https://leetcode.com/problems/number-of-islands/
https://and-some.tistory.com/909
https://leetcode.com/problems/max-area-of-island/submissions/
https://and-some.tistory.com/911
https://leetcode.com/problems/word-ladder/
https://and-some.tistory.com/912
https://leetcode.com/problems/word-search/
https://and-some.tistory.com/913
https://leetcode.com/problems/remove-invalid-parentheses/
https://and-some.tistory.com/914
https://www.lintcode.com/problem/787/
https://and-some.tistory.com/915
https://leetcode.com/problems/path-with-maximum-gold/submissions/
https://and-some.tistory.com/930
https://and-some.tistory.com/936
https://leetcode.com/problems/number-of-provinces/
https://and-some.tistory.com/946
https://leetcode.com/problems/shortest-path-in-binary-matrix/
https://and-some.tistory.com/952
백트래킹
https://leetcode.com/problems/generate-parentheses/
https://and-some.tistory.com/920
https://leetcode.com/problems/permutations/
https://and-some.tistory.com/921?category=1011285
https://leetcode.com/problems/subsets/submissions/
https://and-some.tistory.com/922
https://leetcode.com/problems/letter-combinations-of-a-phone-number/submissions/
https://and-some.tistory.com/923
'Java > Java 알고리즘 모음' 카테고리의 다른 글
[Java 알고리즘] 9. DP 모음 (0) | 2022.11.19 |
---|---|
[Java 알고리즘] 7. 그리디 모음 (0) | 2022.11.15 |
[Java 알고리즘] 6. 큐/스택 모음 (0) | 2022.11.15 |
[Java 알고리즘] 5. 정렬/탐색 모음 (0) | 2022.11.15 |
[Java 알고리즘] 4. Hash/Set 모음 (0) | 2022.11.15 |