P20828 [GeeksforGeeks] Aryas long string5840
普及-
题目描述

Arya has a string, s, of uppercase English letters. She writes down the string s on a paper k times. She wants to calculate the occurence of a specific letter in the first n characters of the final string.
Example
Input :
s = "ABA"
k = 3
n = 7
c = 'B'
Output :
2
Explaination :
Final string - ABAABAABA
Example
Input :
s = "MMM"
k = 2
n = 4
c = 'M'
Output :
4
Explaination :
Final string - MMMMMM
​Your Task:
You don't need to read input or print anything. Your task is to complete the function fun() which takes the string s , integer k ,integer n and the character c as input parameter and returns the occurence of the character c in the first n characters of the final string.
Expected Time Complexity : O(|s|)
Expected Auxiliary Space : O(1)
Constraints:
1 <= |s| <= 10^{5}
1 <= k <= 10^{5}
1 <= n <= |s|*k

输入格式

见题面

输出格式

见题面

样例输入
s = "ABA" k = 3 n = 7 c = 'B'
样例输出
2