백준 24510 시간복잡도를 배운 도도 [Python]

지구온난화·2023년 3월 27일
0

백준 브론즈

목록 보기
37/52
c = int(input())
m = 0
for i in range(c):
    s = input()
    cnt = 0
    for j in range(len(s)):
        if((j+2 < len(s)) and (s[j] == 'f' and s[j+1] == 'o' and s[j+2] == 'r')):
            cnt += 1
            j = j+2
        elif((j+4 < len(s)) and (s[j] == 'w' and s[j+1] == 'h' and s[j+2] == 'i' and s[j+3] == 'l' and s[j+4] == 'e')):
            cnt += 1
            j = j+4
    m = max(m,cnt)

print(m)

2023-03-27

0개의 댓글