-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
09월 23일 백트래킹 #8
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "\uBC31\uD2B8\uB798\uD0B9"
09월 23일 백트래킹 #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
15663 코드리뷰 완료
질문에 대한 답변은 코드리뷰 커멘트에 남겨두었습니다!
이번 백트래킹 과제도 정말 고생 많으셨습니다 🤗❤✨
} | ||
int temp = 0; | ||
//input선언 시에 size를 안 정하면 오류가 나고, size를 정하면 0으로 초기화가 되어 오름차순 정리시 0으로 앞이 채워져 | ||
//아래와 같이 for문을 작성했습니다. for 0부터 n까지로 작성하고 싶다면 어떻게 해야하나요? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n을 입력받고 나서 벡터배열의 크기를 동적으로 할당해주시면 됩니다😊😊
input.assign(n,0);
// 벡터의 크기를 n만큼 동적 할당
check[i] = true; | ||
backTracking(cnt + 1); | ||
check[i] = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요! 이전 수열의 마지막 항과 새로 추가할 값이 같으면 중복된 수열이 된다는 점을 활용하면 되는 문제였어요.
기본 재귀 순열에서 이전에 선택된 값을 저장하는 temp 변수를 사용하여
cnt 번째 같은 숫자가 중복되서 사용되지 않도록 구현해주셨네요!🥰
[추가제출 확인 완료] |
내용 & 질문
<기존 제출>
<추가 제출>