[백준 1181][Python] 단어 정렬

봉글렛·2023년 1월 2일

백준

목록 보기
21/55

문제 링크 https://www.acmicpc.net/problem/1181

sorted 보다 리스트에 sort()로 적용하는게 더 좋음.
값 입력시 함수 사용하면 더 빠르게 읽음.

풀이

import sys
a = set()
for i in range(int(input())):
    a.add(sys.stdin.readline().rstrip())
a = list(a)
a.sort()
a.sort(key=lambda x: len(x))
print('\n'.join(a))
profile
어쩌다 개발자 (할 수 있을 때까지!!!!)

0개의 댓글