Skip to content

[seungyeonchoi] WEEK 04 Solutions - #2970

Open
seungyeonchoi wants to merge 1 commit into
DaleStudy:mainfrom
seungyeonchoi:week-04
Open

seungyeonchoi wants to merge 1 commit into
DaleStudy:mainfrom
seungyeonchoi:week-04

Conversation

@seungyeonchoi

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dalestudy

dalestudy Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

🤖 AI 리뷰(알고리즘 패턴, 시간/공간 복잡도, 학습 현황) 결과는 Checks 탭에서 볼 수 있어요.

@hyedall hyedall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

깔끔하게 설명과 풀이를 잘 작성해주신 것 같습니다 ! 고생하셨습니다 👍

Comment on lines +16 to +27
한 칸 (r, c)에 들어왔다. 지금 word[i]를 찾는 중이다.
1. 격자 밖인지 체크 → 밖이면 실패
2. 이미 방문한 곳인지 체크 → 방문했으면 실패
3. 타겟 글자와 동일한지 체크 → 다르면 실패
4. 마지막 글자였다면 → 성공
5. 방문 표시
6. 상하좌우로 word[i+1]을 찾으러 탐색 → 하나라도 성공하면 성공
7. 방문 표시 해제하고 실패 반환

격자의 모든 칸 (r, c)에서:
위 과정을 i = 0으로 시작 → 성공하면 true
전부 실패하면 false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

풀이 과정을 주석으로 남겨주셔서 리뷰 시에 코드를 파악하기 용이한 것 같습니다 !👍

Comment on lines +71 to +83
if (backTracking(board, word, row-1, col, visited, index+1)) {
return true;
}
if (backTracking(board, word, row+1, col, visited, index+1)) {
return true;
}
if (backTracking(board, word, row, col-1, visited, index+1)) {
return true;
}
if (backTracking(board, word, row, col+1, visited, index+1)) {
return true;
}
visited[row][col] = false;

@hyedall hyedall Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

하나의 visited를 재사용하면서 방문 기록을 복구해 시간복잡도를 개선할 수 있다는 점을 배웠습니다!
상하좌우 탐색 시 방향 배열을 활용하여 중복되는 코드를 줄이는 방식도 고려해보면 좋을 것 같습니다 😊

@parkhojeong parkhojeong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수고하셨습니다! 가독성 관련 커멘트 하나 남깁니다~

Comment on lines +71 to +82
if (backTracking(board, word, row-1, col, visited, index+1)) {
return true;
}
if (backTracking(board, word, row+1, col, visited, index+1)) {
return true;
}
if (backTracking(board, word, row, col-1, visited, index+1)) {
return true;
}
if (backTracking(board, word, row, col+1, visited, index+1)) {
return true;
}

@parkhojeong parkhojeong Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

반복문 활용해서 이런 형태로 개선할 수 있을 거 같아요.

for dx, dy in [(-1,0), (1,0), (0,-1), (0,1)]:
  if (backTracking(board, word, row+dx, col+dy, visited, index+1) return true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants