Distinct subsequences

is there any problem in the logic with my code cuz it fails test cases

hello @Nooberz
check the output format, u are asked to print output by taking mod.

also apply the same mod property at other part of ur computation

it ain’t working it will be helpfull if u can solve my query

pls share ur updated code after adding mods.

@Nooberz
a)
dp[i] = (sum[i - 1]%1000000007 - sum[last[s[i-1]] - 1]%1000000007)%1000000007;

u can subtract only if last[s[i-1]] !=-1 handle that case.
b) check constraint and modify ur array size accordingly
c) use long long

check ur updated code here->

gotchya thanks sir i understand noe

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.