Algorithm/SWEA
[SWEA - D3] 1213. String
hello_u
2023. 5. 4. 20:42
μ£Όμ΄μ§λ λ¬Έμμ΄μμ νΉμ ν λ¬Έμμ΄μ κ°μλ₯Ό λ°ννκΈ°κΈ° Starteatingwellwiththeseeighttipsforhealthyeating,whichcoverthebasicsofahealthydietandgoodnutrition.
μ λ¬Έμ₯μμ ti λ₯Ό κ²μνλ©΄, λ΅μ 4μ΄λ€.
λμ μ½λ
for _ in range(1, 11):
t = int(input())
s1 = input()
s2 = input()
s1L = len(s1)
s2L = len(s2)
cnt = 0
for i in range(s2L-s1L+1):
if s2[i:s1L+i] == s1:
cnt += 1
print("#"+str(t) , cnt )
νμ΄μ¬μλ count ν¨μκ° μλ€.
μκ° μλμ λ¬Έμμ΄ μ¬λΌμ΄μ±ν΄μ λ°λ³΅λ¬Έλλ¦¬κ³ λΉκ΅ν΄μ νμλ€.
count ν¨μλ₯Ό μ΄μ©ν νμ΄
for _ in range(10):
n = int(input())
find_str = input()
s = input()
print(f'#{n} {s.count(find_str)}')