본문 바로가기
python-algorithm

백준 19564 반복

by 무적김두칠 2023. 11. 27.

https://www.acmicpc.net/problem/19564

 

19564번: 반복

muse가 입력하고자 하는 글 $S$가 주어진다. 이 글은 알파벳 소문자만으로 이루어져 있으며, 길이는 $L$이다. ($1 \le L \le 10^5$)

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
def solution(s):
    answer = 1
    for i in range(1len(s)):
        if ord(s[i]) <= ord(s[i -1]):
            answer += 1
        else:
            continue
    return answer
 
if __name__ == '__main__':
 
    s = input()
    print(solution(s))
 
cs
반응형

'python-algorithm' 카테고리의 다른 글

백준 16283 Farm  (2) 2023.11.28
백준 1440 타임머신  (1) 2023.11.28
백준 30700 KOREA 문자열 만들기  (1) 2023.11.27
백준 28062 준석이의 사탕 사기  (1) 2023.11.27
백준 26529 Bunnies  (1) 2023.11.25

댓글