Permuation Question : Number of Strings with no K consequetive equal letters given the string is made of lower case alphabets
Read here : Explanation It has beautiful solution using recurrence formulaes.
Basically the Recurrence is :
if k == n: ways[n] = (power(26,k) - 26)
if n <= k - 1: ways[n] = power(26,n)
else ways[n] = (countValid(n-1,k) + countValid(n-k,k))
You need to take care of modular arithmetic of course as the numbers get really large BTW it was there in Atlassain OA — best OA ever
C++
python