You are viewing a single comment's thread. Return to all comments →
Solving with complexity O(1) - In python3
given_string = input() n = int(input()) n_by_givstring = int(n/len(given_string)) extra_string_required = n%len(given_string) extra_string = given_string[:extra_string_required] char_count_in_orig_str = given_string.count('a') extra_count = extra_string.count('a') output = n_by_givstring*char_count_in_orig_str output+=extra_count print(output)
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 →
Solving with complexity O(1) - In python3