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.
Of course, 'ca' is the remaining 'a' characters, while 'c' is the total amount of characters in the given string without the remaining. 'r' is the remaining that doesn't fit into the 'n', so ((n - r) / s.length * c) is the amount of characters whitout the remainings of 'a' characters. The remaining must be counted only if is not greater than the index (i < r). So the total amount without the remaining + the remaining 'ca' is the result.
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 →
Of course, 'ca' is the remaining 'a' characters, while 'c' is the total amount of characters in the given string without the remaining. 'r' is the remaining that doesn't fit into the 'n', so ((n - r) / s.length * c) is the amount of characters whitout the remainings of 'a' characters. The remaining must be counted only if is not greater than the index (i < r). So the total amount without the remaining + the remaining 'ca' is the result.