본문 바로가기
문제 풀이/백준

[백준] 11656번 접미사 배열

by ginny. 2023. 12. 2.

 

 

# 파이썬 리스트 컴프리헨션

리스트 컴프리헨션 = 직관적으로 리스트를 생성하는 방법 (한줄에 표현 가능)

 

아래와 같이 대괄호 안에 함수도 적용 가능

def test(x):
    x = str(x)+'ab'
    return x
 
[test(i) for i in range(5)]

 

 

[해결]

def suffix(string,i):
    return string[i:]
    
from operator import itemgetter
import sys
input=sys.stdin.readline
print=sys.stdout.write

words=[]
s=input().rstrip()
# for i in range(len(s)):
#     words.append(suffix(s,i))
words=[suffix(s,i) for i in range(len(s))]
sorted_words=sorted(words)
print("\n".join(map(str,sorted_words)))

댓글