You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
현재 알고리즘은 두 번의 반복문을 사용하여 O(n²) 시간 복잡도를 가집니다. 트라이(Trie) 자료구조를 사용하면 시간 복잡도를 O(nm)로 개선할 수 있습니다.
functionsolution(phone_book){constnumberSet=newSet();for(constnumberofphone_book){// 같은 전화번호가 중복해서 들어있지 않으므로 끝번호를 제외한 부분문자열만 구해준다.for(letlen=1;len<number.length;len++){numberSet.add(number.substr(0,len));}}for(constnumberofphone_book){if(numberSet.has(number)){console.log(number);returnfalse;}}returntrue;}
function solution(phone_book) {
const numberSet = new Set();
for (const number of phone_book) {
- // 같은 전화번호가 중복해서 들어있지 않으므로 끝번호를 제외한 부분문자열만 구해준다.
for (let len = 1; len < number.length; len++) {
- numberSet.add(number.substr(0, len));+ const prefix = number.substr(0, len);+ if (numberSet.has(prefix)) return false;
}
- }-- for (const number of phone_book) {- if (numberSet.has(number)) {- console.log(number);- return false;- }+ numberSet.add(number);
}
return true;
}
Suggestion importance[1-10]: 8
__
Why: The suggestion removes unnecessary console.log and optimizes the algorithm by checking prefixes in a single pass, reducing time complexity and improving code efficiency.
Medium
코드 가독성 및 성능 개선
현재 코드는 기본적으로 잘 작성되었지만, 가독성과 성능을 개선할 수 있습니다. 조기 반환 패턴을 사용하여 중첩된 조건을 줄이고, 코드의 명확성을 높일 수 있습니다.
Why: The suggestion improves code readability by introducing clearer variable names and simplifying the logic. The core algorithm remains unchanged, making it a moderate improvement.
Medium
yoouyeon
changed the title
2025-12-06 문제 풀었어요
2025-12-05 문제 풀었어요
Dec 6, 2025
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
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.
User description
오늘도 멋져요 👍✨
PR Type
Enhancement
Description
프로그래머스 레벨 2 문제 두 개 해결
영어 끝말잇기 알고리즘 구현
전화번호 목록 중복 검사 로직 추가
README.md에 문제 정보 업데이트