samadeep's blog

By samadeep, history, 7 months ago, In English

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
  • Vote: I like it
  • +6
  • Vote: I do not like it

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

WHy the downvote my friends ?

»
7 months ago, # |
  Vote: I like it +5 Vote: I do not like it

I upvoted.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

is this blog really necessary?

  • »
    »
    7 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Its actually something i found interesting as a problem for understanding why permutations and combinations using binomial coefficients are slower than recursive techniques

    Ofcourse on necessity i have no comments its just that i found this interesting Any criticism is welcome.