[PGS] 옹알이(2) - #59
Open
been12151 wants to merge 11 commits into
Open
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.
🍪 문제 이름
Resolve: 옹알이 (2)
🍊 문제 정의
inputbabbling: 머쓱이 조카가 옹알이한 단어들이 담긴 문자열 배열 (1 ≤ 길이 ≤ 100, 각 단어 길이 1 이상 30 이하, 알파벳 소문자로만 구성)outputbabbling중 "aya", "ye", "woo", "ma"의 조합으로만 이루어지고, 같은 발음이 연속되지 않는 단어의 개수예시
🍑 알고리즘 설계
각 단어에 대해 4가지 발음(
words)을 순서대로 찾아발음 + " "로 치환함. 치환 후split()으로 분리하면 발음 단위의 리스트(parts)가 만들어짐.parts의 모든 원소가words에 속하는지 확인하고,groupby(parts)로 연속된 같은 발음이 없는지 동시에 체크해서 둘 다 통과하면 카운트 증가.🥝 최악 수행 시간 복잡도
O(n × m)(n = babbling의 길이, m = 각 단어의 길이)replace()를 수행하고(상수), 이후split(),all(),groupby()모두 단어 길이에 비례하므로 전체 O(n × m)🍰 특이 사항 (Optional)
연속된 같은 발음 체크를
groupby()로 처리