Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

09월 23일 백트래킹 #8

wants to merge 3 commits into from

Conversation

songing01
Copy link
Contributor

@songing01 songing01 commented Sep 29, 2022

내용 & 질문

과제 제출합니다!

<기존 제출>

15663

<추가 제출>

10971

Copy link

@flowersayo flowersayo left a 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까지로 작성하고 싶다면 어떻게 해야하나요?

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;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞아요! 이전 수열의 마지막 항과 새로 추가할 값이 같으면 중복된 수열이 된다는 점을 활용하면 되는 문제였어요.
기본 재귀 순열에서 이전에 선택된 값을 저장하는 temp 변수를 사용하여
cnt 번째 같은 숫자가 중복되서 사용되지 않도록 구현해주셨네요!🥰

@kwakrhkr59
Copy link

[추가제출 확인 완료]
안녕하세요 지민님~ 추가제출 확인 완료되셨습니다😊
이번 과제도 수고 많으셨습니다:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants