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(s:str,n:int):# Number of letter A in sn_of_a=s.count("a")#Lenght of sn_of_letters=len(s)# number of s based on n , rest of s if exist number_of_substring,rest_of_substring=divmod(n,n_of_letters)# number of letter A in the rest of srest=s[0:rest_of_substring].count("a")# so every substring there exist number of A Letter + rest if exist result=(number_of_substring*n_of_a)+restreturnresult
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 →
Time Complexity :