Whats wrong in this code

Hey,you are not taking mod.It might be possible that the count is greater than integer limit.Take mod and try submitting again.

This is how to take mod:

dp[i]=(2*dp[i-1])%mod;
if(previous_count[s[i-1]]!=-1)
dp[i]=(dp[i]-dp[previous_count[s[i-1]]-1]+mod)%mod;

what should be value of mod

It is given in the question. Please check it