Conversation
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 이슈 번호
Resolve: {#2319}
🧩 문제 해결
스스로 해결: ✅
🔎 접근 과정
다른 문제들을 푸는 것처럼 DFS을 진행하되 방문 처리에 유의가 필요하다.
루프가 생기는 지점을 감지하기 위해 "방문" 자체는 -1로 표기하고,
순회를 마친 경로에 대해선 재탐색을 진행할 때의 시간복잡도 개선을 위하여 메모라이제이션을 진행한다.
⏱️ 시간 복잡도
O(RC)메모라이제이션을 통해 이미 방문한 지점은 추가 방문하지 않으므로
최대 board의 크기만큼 진행된다.
💻 구현 코드