Development/Algorithm & Coding Test
[파이썬, Python] 백준 1181번 : 단어 정렬
컴공 K
2021. 8. 8. 00:01
728x90
백준 1181번 : 단어 정렬

내 코드
import sys
n = int(input())
word_list = []
for _ in range(n):
word_list.append(sys.stdin.readline().strip())
word_list = list(set(word_list)) # 중복 제거
word_list.sort(key = lambda x: (len(x), x)) # 정렬
result = "\n".join(word_list)
print(result)
728x90
반응형