완전탐색으로 구현
import java.util.*;
import java.io.*;
public class Main {
static int N;
static Vector<Integer> v;
static Stack<Integer> st;
static void print(){
if(st.size()==N) {
for(int num:st){
System.out.print(num+" ");
}
System.out.println();
return;
}
for(int i=1;i<N+1;i++){
if(!st.contains(i)){
st.add(i);
//System.out.println(i);
print();
st.pop();
}
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(br.readLine());
st = new Stack<>();
print();
br.close();
}
}
쓸 수 있는 문제가 많으니 확실히 이해하고 암기하기..!
'algorithm > 문제 풀이' 카테고리의 다른 글
99클럽 코테 스터디 8일차 TIL - 백준 1931 (회의실배정) (0) | 2024.04.08 |
---|---|
백준 1654번 (랜선 자르기) 자바 Java (0) | 2024.04.07 |
99클럽 코테 스터디 6일차 TIL - 프로그래머스 문자열 내 마음대로 정렬하기 (0) | 2024.04.06 |
99클럽 코테 스터디 4일차 TIL - 프로그래머스 문제 : 할인 행사 (1) | 2024.04.04 |
99클럽 코테 스터디 2일차 TIL - 백준 11279 (최대 힙) java (0) | 2024.04.02 |