해시 문제라길래 해시로 풀려고 엄청 고민했다.
효율성 3, 4번이 계속 실패해서 5시간 넘게 고민해본 문제.
결국 질문하기에 올라온 설명보고 성공했다.
효율성을 좀 더 고려하면서 풀수 있도록 해봐야겠다.
def solution(phone_book):
answer = True
phone_nums = sorted(phone_book)
for i in range(1, len(phone_nums)):
prev_num = phone_nums[i-1]
current_num = phone_nums[i]
if(current_num.startswith(prev_num)):
return False
return answer
'공부 스걱스걱 > 코딩테스트' 카테고리의 다른 글
[python3] 프로그래머스_숫자 문자열과 영단어 (0) | 2021.09.10 |
---|---|
[python3] 프로그래머스_기능개발 (0) | 2021.07.02 |
[python3]프로그래머스_내적 (0) | 2021.05.21 |
[python3]프로그래머스_모의고사 (0) | 2021.05.18 |
[python3]프로그래머스_신규 아이디 추천 (0) | 2021.05.17 |