is this problem can be solved using top down dp…?
Count distinct subsequence
Hi @nikhilmeena,
yes it can be solved using top down dp also.
u can use the following approach.
DP[i] = DP[i-1]*2 - DP[Immediate previous occurence of character S[i-1]], if S[i-1] has occurred before.
Try to think of how dis comes and try taking some examples.
if u feel like u r facing some problem, feel free to post ur doubt here.
If u want, i can provide d code for d problem as well.
But first try to think about the above relation.
Hope dis will help.
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.