You are viewing a single comment's thread. Return to all comments →
//Java
public static long repeatedString(String s, long n) { long result; long fullRepeat = n/s.length(); long reminder = n % s.length(); result = countA(s)*fullRepeat+ countA(s.substring(0, (int) reminder)); return result; } public static long countA(String str){ long count = 0; for(char c : str.toCharArray()){ if(c=='a') count++; } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →
//Java