https://www.acmicpc.net/problem/1543
string.find로 key(찾는 문자열)의 index를 구한 후, index 지점부터 key 길이만큼 1로 치환하고, 단어 count을 1 증가시킨다
string.find로 key가 검색되지 않을 때까지 while문으로 반복한다
count를 반환한다
n = str(input())
key = str(input())
count=0
while True:
if n.find(key)==-1:
break
else:
count+=1
idx = n.find(key)
s = list(n)
for i in range(idx,idx+len(key)):
s[i]="1"
n = ''.join(s)
print(count)
'개발자 강화 > 코딩 테스트' 카테고리의 다른 글
[백준] 20044 Project Teams / 구현 / 실4 (0) | 2025.01.03 |
---|---|
[백준] 22233 가희와 키워드 / 구현 / Python 실3 (0) | 2024.12.11 |
[백준] 17266 어두운 굴다리 / 이진탐색 / Python 실4 (0) | 2024.12.11 |
[백준] 1522 문자열 교환 / 구현 / python 실1 (0) | 2024.12.04 |
[백준] 1283 단축키지정 / 구현 / Python 실1 (0) | 2024.12.03 |