Answered step by step
Verified Expert Solution
Question
1 Approved Answer
There is a string, s , of lowercase English letters that is repeated infinitely many times. Given an integer, n , find and print the
There is a string, s of lowercase English letters that is repeated infinitely many times. Given an integer, n find and print the number of letter as in the first letters of the infinite string.
Example
s'abcac'
n
The substring we consider is abcacabcac, the first characters of the infinite string. There are occurrences of a in the substring.
Function Description
Complete the repeatedString function in the editor below.
repeatedString has the following parameters:
s: a string to repeat
n: the number of characters to consider
Returns
int: the frequency of a in the substring
Input Format
The first line contains a single string, s
The second line contains an integer, n
Constraints
s
n
For of the test cases, n
Sample Input
Sample Input
aba
Sample Output
Explanation
The first n letters of the infinite string are abaabaabaa. Because there are as we return
Sample Input
a
Sample Output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started