def solution(words):
words.sort()
prefix_set = set()
for i in range(1, len(words)):
w1, w2 = words[i-1], words[i]
for j in range(1, min(len(w1), len(w2))+1):
if w1[:j] == w2[:j]:
prefix_set.add(w1[:j])
else:
break;
answer = 0
for w in words:
for i in range(1, len(w)+1):
answer += 1
if w[:i] not in prefix_set:
break;
return answer
# https://school.programmers.co.kr/learn/courses/30/lessons/17685'Data Engineering > Python' 카테고리의 다른 글
| [코테] 프로그래머스 - 이중우선순위큐 (0) | 2025.12.01 |
|---|---|
| [코테] 프로그래머스 - 스티커 모으기(2) Python 코드 (0) | 2025.11.27 |
| [코테] 프로그래머스 - 거스름돈 Python 코드 (0) | 2025.11.03 |
| [코테] 프로그래머스 - [1차] 셔틀버스 Python 코드 (0) | 2025.10.31 |
| [코테] 프로그래머스 - 길 찾기 게임 Python 코드 (0) | 2025.10.25 |