Merged
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: {#2325}
🧩 문제 해결
스스로 해결: ❌
🔎 접근 과정
주어진 수에 대하여 왼쪽에서 오른쪽 순으로 / 오른쪽에서 왼쪽 순으로 최대 공약수들을 누적시킨 배열을 선언한다.
어느 index를 제거한다고 했을 때, gcd(L2R[i - 1], R2L[1 + 1]) 를 통해 최대공약수를 할 수 있다.
따라서 배열을 순회하면서 최대가 되는 최대 공약수를 찾고,
제거한 수와 최대공약수가 나누어 떨어지는가를 체크하여 결과를 추출하면 된다.
⏱️ 시간 복잡도
O(N * log N)유클리드 호제법은 log N의 시간복잡도를 가지고 있으며,
해당 알고리즘을 N번 수행하므로 O(N * log N) 이다.
💻 구현 코드