Find number of ways to create a string

This is what I would do in contest:-

  1. O(N) , if it fails,
    2)A nice formula comes from the dp we apply, just paste it :stuck_out_tongue: :slight_smile:
1 Like

This is pleasant to my eyes.

O(N * T) actually passed with 0.1 secs.

I actually wasnt in the contest but few guys said that it TLE’s so I was trying to reason. You are correct. It should pass.

It creates TLE, I tried it. We will need better algorithm.