[python] 백준 1316번 오답노트

김보현·2024년 6월 10일
0

PS

목록 보기
23/62

sorted 함수 활용

list를 제자리에서(in-place) 수정하는 내장 list.sort() 메서드
iterable로부터 새로운 정렬된 리스트를 만드는 sorted() 내장 함수

key=word.find: 알파벳 순서가 아닌, 첫 등장한 위치부터 중복되는 단어 나열

result = 0
n = int(input())
for i in range(n):
    word = input()
    if list(word) == sorted(word, key=word.find):
        result += 1
print(result)
profile
Fall in love with Computer Vision

0개의 댓글

관련 채용 정보