def repeatedString(s, n):
# Write your code here
s_len = len(s)
if s_len == 1 and s == 'a':
return n
else:
a_num = 0
for i in s:
if i == 'a':
a_num +=1
a_num = a_num * (n // s_len)
if n % s_len != 0:
for i in range(n % s_len):
if s[i] == 'a':
a_num += 1
return a_num
'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글
[HackerRank-python] Equalize the Array (0) | 2022.08.24 |
---|---|
Jumping on the Clouds (0) | 2022.08.23 |
[HackerRank-python] Non-Divisible Subset (0) | 2022.08.14 |
[HackerRank-python] Cut the sticks (0) | 2022.08.11 |
[HackerRank-python] Library Fine (0) | 2022.08.09 |