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.
double r = 0;
foreach (char c in s)
{
if (c == 'a')
{
r++;
}
}
r = ( r * (n/ s.Length));
for (int i = 0; i < n % s.Length; i++)
{
if (s[i] == 'a')
{
r++;
}
}
return Convert.ToInt64(r);
PS.: Not tested against "n < len(s)".
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 →
Based on your code i reached the solution below:
PS.: Not tested against "n < len(s)".