Conversation
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.
🧷 문제 링크
https://www.acmicpc.net/problem/10942
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
수열중 특정 구간이 팰린드롬인지 확인하는 문제.
🔍 풀이 방법
맨 끝만 비교하고 그 내부가 팰린드롬인지 아닌지를 dp로 저장해두고 사용했다.
1213121에서 2부터 6까지가 팰린드롬인지 아닌지를 판단할때, str[2] != str[6]이면 dp[2][6] = 0, str[2] == str[6] 이면 dp[3][5]의 값을 그대로 따라가는 방식.
⏳ 회고
문자열이 팰린드롬인지 아닌지 판단하는 건 O(N)
모든 부분 문자열에 대해서 팰린드롬인지 판단하는건 원래 O(N^3)인데, dp를 이용해서 O(N^2)까지 줄일 수 있음.
manacher 알고리즘을 사용하면 O(N+N)으로 가능한데 어려워서 포기함 ㅋ. 혁준이가 설명해주겠지?