-
-
Notifications
You must be signed in to change notification settings - Fork 305
[dylan-jung] WEEK 04 solutions #2131
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
Conversation
radiantchoi
left a comment
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.
안녕하세요! 이번 주 리뷰를 해 드리게 되었습니다. 제가 C++을 처음 읽어보네요..! 한편 저도 푼 것에 대해서 경험을 바탕으로 이런저런 이야기를 나눠볼 수 있겠습니다만, 풀지 못한 혹은 않은 것에 대해서는 제 생각이 미치지 못 할 수 있습니다. 상기 사유로 인해 피드백이 부족할 수 있는 부분은 양해 부탁드립니다. 이번주도 고생 많으셨습니다!
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.
dp 배열을 무한대로 초기화하셨군요! 대개 이런 경우 방문 처리를 해야 한다고 하나요.. 저는 이 문제를 바로 풀지는 못하고 태그를 토대로 방법을 유추만 해 봤는데, dp 배열을 -1로 초기화했습니다. 결국 if가 반환할 때랑 값을 갱신할 때, 어디에 들어가냐 문제인 것 같기는 해요.
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.
깊이를 나타내는 인수를 들고 dfs하는 문제였죠. 직관적으로 풀어주신 듯 합니다.
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.
leetcode 특유의 리스트 관리 방법에서 제가 꽤 어려움을 많이 겪었던 기억이 납니다. 결국 연결 리스트는 참조 기반으로 이루어지고, 포인터를 기반으로 더미 노드를 맨 앞에 둔 다음 반환시 next를 사용한다는 것 말이죠.. 리스트1과 리스트2 중 남는 것을 이어붙이는 부분에서 매우 깔끔하게 해 주셨다는 생각이 듭니다.
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.
visited 방식을 사용하셨군요! 탐색 문제에서는 visited 배열의 사용을 생활화해야 하나, 하는 생각이 듭니다. 저는 주어진 배열의 글자를 특수문자로 바꾸고 원상복구 시켜가면서 백트래킹을 사용했는데 아무래도 좀 헷갈리더군요.
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.
그것도 백트래킹에서 사용하기에 좋은 방법인 듯합니다!
그 방법에서 잠깐 생각해보니 다음과 같은 탐색 상황일 때,
char mem = arr[i][j];
arr[i][j] = '+'
dfs(next)
arr[i][j] = mem;
처럼 결국 mem이라는 변수를 결국 만들어서 스택 영역에 저장해야한다는 점 때문에 bool 배열인 visited가 살짝 더 좋아보이긴 하네요. 사소한 차이라서 편한거 쓰서도 좋을 것 같습니다!
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트