Why i am getting wrong ans…
Only first test case is getting passed…
Count Subsequence Dp
@Ram_Vilash_Kumar
you are required to take modulo with 1000000007, so that values does not go beyond that.
add these:-
dp[i]=(2*dp[i-1])%mod;
dp[i]=(mod + dp[i]-dp[last[pos]])%mod; // adding mod is done because there may be a chance due to taking modulo dp[i] may become negativee, so just to maintain the value above zero.
@Ram_Vilash_Kumar
After doing these changes, your code will pass.
So if you don’t have further doubt then please mark this doubt as resolved.
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.