We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f0bde0d commit bfb3459Copy full SHA for bfb3459
Hongjoo/lv2/전화번호목록.py
@@ -0,0 +1,26 @@
1
+"""
2
+https://school.programmers.co.kr/learn/courses/30/lessons/42577
3
4
+
5
+def solution(phone_book):
6
+ answer = True
7
+ #1. 글자수로 정렬하기
8
+ phone_book = sorted(phone_book , key = lambda x : (len(x)))
9
+ #2. key = 전번인 해쉬맵 생성
10
+ hash_map = {}
11
+ for phone in phone_book :
12
+ hash_map[phone] = 1
13
+ #3. hashmap에 접두어 비교하기
14
15
+ tmp = ""
16
+ # 접두어 한 글자씩 추가해서 hasp_map의 key들 중에 같은게 있는지 확인
17
+ for n in phone :
18
+ tmp += n
19
+ if tmp in hash_map and tmp!= phone :
20
+ answer = False
21
22
23
24
25
26
+ return answer
0 commit comments