We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- All Contests
- HourRank 12
- Repeated String
- Discussions
Repeated String
Repeated String
Sort by
recency
|
14 Discussions
|
Please Login in order to post a comment
This is my solution
This is my solution
package hackerrankcode;
import java.io.; import java.math.BigInteger; import java.util.;
public class Repeated_String {
//}
this is my solution
public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); long n = in.nextLong();
import sys
s = input().strip() n = int(input().strip())
l = len(s) if(l==1 and s=='a'): print(n) else: c = s.count('a') c *= n//l s = s[:(n%l)] c+=s.count('a') print(c)
!/bin/python3
import sys
s = input().strip() n = int(input().strip()) c=s.count('a') f=int(n/len(s)) r=n%len(s) print(c*f+s[0:r].count('a'))