728x90
1. 문제
2. 해결방안
- 입력 받은 단어의 중복 제거
- 입력 받은 단어 알파벳 순으로 정렬
- 입력 받은 단어 길이순으로 오름차순
sort()를 알면 어렵지 않은 문제였다 !
3. 코드
n =int(input())
words = []
for i in range(n):
words.append(input())
words.sort() #알파벳 순 정렬
words.sort(key = len) # 길이 순 정렬
ans = []
#중복제거
for word in words:
if word not in ans :
ans.append(word)
for word in ans:
print(word)
'[알고리즘] > BOJ' 카테고리의 다른 글
[백준/Python] 15905번: 스텔라(STELLA)가 치킨을 선물했어요 (람다함수 정렬) (0) | 2023.02.24 |
---|---|
[백준/Python] 5533번 : 유니크 (이중리스트에서 중복체크) (0) | 2023.02.24 |
[백준/Python] 10798번 : 세로읽기 (0) | 2023.02.21 |
[백준/Python] 기초 10제 - Day4 (0) | 2023.02.16 |
[백준/Python] 기초 10제 - Day3 (0) | 2023.02.14 |