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.
/* * Complete the 'repeatedString' function below. * * The function is expected to return a LONG_INTEGER. * The function accepts following parameters: * 1. STRING s * 2. LONG_INTEGER n */functionrepeatedString(s,n){letcountInOriginal=0;for(letcofs){countInOriginal+=c==='a'?1:0;}letfullRepeats=Math.floor(n/s.length);letcount=fullRepeats*countInOriginal;letremaining=n%s.length;for(leti=0;i<remaining;i++){count+=s[i]==='a'?1:0;}returncount;}
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 →
JavaScript Solution