Lilah has a string, s , of lowercase English letters that she repeated infinitely many times.

Given an integer, n, find and print the number of letter a‘s in the first n letters of Lilah’s infinite string.

For example, if the string s=’abcac’ and n=10, the substring we consider is ‘abcacabcac’ , the first 10 characters of her infinite string. There are occurrences 4 of a in the substring.

More information about this ‘problem’ can be found at: https://www.hackerrank.com/challenges/repeated-string

Author

Write A Comment