Skip to content

Commit 1dfb830

Browse files
committed
[BOJ]문자열교환/ Silver / 30min
https://www.acmicpc.net/problem/1522
1 parent 8f2cf3f commit 1dfb830

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Hongjoo/백준/문자열교환.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
https://www.acmicpc.net/problem/1522
3+
"""
4+
5+
words= input()
6+
window_size = words.count("a") # 1. a의 개수 = sliding window 크기
7+
result = 999999999
8+
9+
# 원형 문자열
10+
words += words[0:window_size-1]
11+
# 2. 최대한 a 가 연속해 있는 idx 범위 찾기
12+
for start in range(len(words) - (window_size-1)):
13+
result = min(result, words[start: start+ window_size].count("b"))
14+
15+
print(result)

0 commit comments

Comments
 (0)