• + 0 comments

    JavaScript Solution

    let length =s.length,count=1,repeactChar='a'; let repetWord = Math.floor(n/length); let remainderChar = n%length;; for(let i = 0; i < length; i++){ if(repeactChar == s[i]) count++; } count = count * repeatWord; for(let j = 0; j < remainderChar; j++){ if(repeactChar ==s[j]) count++; } return count