[20250514] BOJ / G4 / 사전 순 최대 공통 부분 수열 / 이강현#333
Merged
ShinHeeEul merged 1 commit intomainfrom May 14, 2025
Merged
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/30805
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
두 수열에서 순서를 고려하는 공통 수열에 대해서 사전 순으로 가장 나중에 나오는 공통 수열을 출력하는 문제
🔍 풀이 방법
그리디 알고리즘
⏳ 회고
두 수열을 모두 순회하여 공통된 원소들중 가장 큰 원소의 인덱스를 찾아냄. 어차피 사전 순 가장 뒤인 수열 하나만 출력하는 거니까 가장 큰 공통 원소가 맨 앞에 오는게 무조건 제일 큰 경우임. 그리고 가장 큰 게 여러개 있을 수도 있으니 그 중 가장 앞에 있는 인덱스를 뽑기 위해 수열 뒤에서부터 순회하기로 함.
그리고 한번 순회하여 인덱스를 구했다면 리스트에 추가하고 또 맨 뒤에서부터 찾은 인덱스 바로 뒤까지만 순회함. 이를 반복하여 더 이상 공통 원소를 찾아내지 못하면 리스트를 출력함.
그냥 생각나는대로 풀었는데 맞아서 기분이 좋다 ㅎ