Thanks for explaining , code is simple, only understanding is the main part. It will be nice if u could explain 2 examples separately by making a full dig. from starting till all subsequences are covered. Once ex. is understood, code is doable if anyone has covered the basic. Thanks again. Tc.
@PlacementsReady Жыл бұрын
Ok thanks for the suggestions
@abhishekkumar-gi5xm Жыл бұрын
it is not necessary to make us understand in english ... hindi me smjhate to aacha rehta.. aur aache se smjh me aata
@PlacementsReady Жыл бұрын
Where u faced the issue ?
@HarshGuptaNITP Жыл бұрын
why you subtracted dp[index-1]? as the answer is stored in in dp[index]as dp[0]=1, dp[1]=2 so you are following one based indexing
@PlacementsReady Жыл бұрын
We need to ignore the subsequence that contains that character that is why index-1
@sushantsuman4329 Жыл бұрын
why ggf output is 6 and gfg is 7? both are same
@PlacementsReady Жыл бұрын
Do a dry run according to algo u will understand
@nithinn2632 Жыл бұрын
in string "gfg", why "ggf" and "fgg" is not a substring?
@rainywinter459 Жыл бұрын
We are finding subsequences not substring
@PlacementsReady Жыл бұрын
Bro by mistake I told substring while explaining
@PlacementsReady Жыл бұрын
Order should be followed that's why ggf and fgg is not a subsequence
@ScaraB01 Жыл бұрын
Can u tell in python
@piyushverma1303 Жыл бұрын
def distinctSubsequences(self, s): dp=[0]*(len(s)+1) dp[0]=1 mp={} for i in range(1,len(s)+1): dp[i]=2*dp[i-1] if s[i-1] in mp: dp[i]=(dp[i]-dp[mp[s[i-1]]-1])%1000000007 mp[s[i-1]]=i return dp[len(s)]
@PlacementsReady Жыл бұрын
For reference Java and python code is attached in description of video