코딩테스트 고득점 Kit - 해시 2 (Level 2)

 

https://programmers.co.kr/learn/courses/30/lessons/42577


Code

1. Set

1
2
3
4
5
6
7
8
9
def solution(phone_book):
    nums = set(phone_book)
    for num in phone_book:
        tmp = ""
        for n in num[:-1]:
            tmp += n
            if tmp in nums:
                return False
    return True

Complexity

$O(n)$

  • $n$ = len(phone_book)