CS/백준, 프로그래머스 풀이
[1181] 단어정렬
JDJ
2022. 5. 27. 00:08
https://www.acmicpc.net/problem/1181
Point.
1. 중복단어 제거
2. sort에 key를 사용하여 문제해결
3. (len(x), x) 스킬
요구사항이 글자수로 먼저 정리 후
(4, more) , (2, no) ,(2, it) ...
글자수 먼저 정렬 후 -> 문자열 정렬이 들어간다.
n = int(input())
item_list = []
for _ in range(n):
item_list.append(input())
item_list = list(set(item_list)) #중복단어 제거
item_list.sort(key=lambda x : (len(x), x))
for i in item_list:
print(i)