Problem -> Problem

I am trying something similar to digit dp where we need to find the number of numbers in the range a to b satisfying some property, just in this case we have strings.

My helper function is actually calculating the number of good strings which are lexicographically less than or equal **s** and do not contain the substring evil.

Then I simply subtract the answer for two cases.

**Please help me it's almost two weeks**

**Spoiler**

This solution only passes 15 test cases. Help me please.

Auto comment: topic has been updated by Mikemirzyanov1 (previous revision, new revision, compare).Note that usual answer to range query $$$[L,R]$$$ dynamic-programming counting problems should be $$$dp[R]-dp[L-1]$$$. Therefore, the answer should be subtracting the results of the two cases $$$s2$$$ and $$$prev(s1)$$$, where $$$prev(s1)$$$ is the previous $$$n$$$-letter lexicographically ordered string.

He added $$$c$$$ for the same.

I have a solution for this problem. Will explain in more detail in some time.

Short-explanation :-

1)First see how to count the number of strings between s1 and s2 . Let n1 = number of strings between (aaaaaaa...a and s1) , n2 = number of strings (aaaaa...aaaa and s2) , hence, answer = n2-n1+1 . (can be calculated easily with dp)

2)If you know how to do the step-1 , you will realize, that you only need to know, for each length-'i' (from aaaaa--->zzzzz(here, i = 5) , the number of strings which contains the substring "s3" atleast once, if you know it for length 'i' , transition to state 'i+1' is easy.

3)If you want the exact recurrence relations , I'll write them .

Did you left this one karangreat234 just because you become pupil in that? That much arrogance is not good for anyone.

He is the only one in

karangreat234 Fan ClubLoL.Just showoff skill.

I am asking why is my approach of tackling this with digit dp giving wrong answer??

For those who don't know about DFA I constructed a DFA for the string evil (i.e the DFA would reject all the strings which contains evil as a substring).

Then I used simple digit dp with two tights (t1,t2) for strings s1,s2 respectively and checked whether the the string is accepted by the DFA or not.

Here is my CODE it took 108ms to run(faster than all the codes submitted so far) Note the header files are missing as they are already included in leetcode's IDE.

Hi Brownie can you help me understanding what is wrong in my approach .

Thanks.

Auto comment: topic has been updated by Mikemirzyanov1 (previous revision, new revision, compare).HELP

Someone please help me.

On this testcase:

You code output's 25, but the answer is 24.

Auto comment: topic has been updated by Mikemirzyanov1 (previous revision, new revision, compare).