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.
defrepeatedString(string:str,substring_size:int)->int:# This code can be simplified, but maintainability wins# How many characters are in the repeating stringsize:int=len(string)# If the number of times the string repeats has remainder, account itlast_position:int=substring_size%size# Number of times the string repeats entirelyfull_repeats:int=substring_size// sizereturnstring.count('a')*full_repeats+string[0:last_position].count('a')
Cookie support is required to access HackerRank
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 →
Python