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 a’s in the first n letters of the infinite string.
The substring we consider is abcacabcac, the first 10 characters of the infinite string. There are 4 occurrences of a in the substring.
Complete the repeatedString function in the editor below.
repeatedString has the following parameter(s):
- s: a string to repeat
- n: the number of characters to consider
- int: the frequency of a in the substring
The first line contains a single string,s .
The second line contains an integer,n .
- For 25% of the test cases,n<=10^6 .
Sample Input 0
Sample Output 0
The first n=10 letters of the infinite string are abaabaabaa. Because there are 7 a’s, we return 7.
Sample Input 1
Sample Output 1
Repeated String HackerRank Solution in C
char* s = (char *)malloc(512000 * sizeof(char));
Repeated String HackerRank Solution in C++