#125

Поделиться
HTML-код
  • Опубликовано: 28 дек 2024

Комментарии • 17

  • @52nevil36
    @52nevil36 Год назад +2

    thanks bro

  • @eklavya22k34
    @eklavya22k34 Год назад +2

    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.

  • @HarshGuptaNITP
    @HarshGuptaNITP Год назад +1

    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
      @PlacementsReady  Год назад

      We need to ignore the subsequence that contains that character that is why index-1

  • @abhishekkumar-gi5xm
    @abhishekkumar-gi5xm Год назад +2

    it is not necessary to make us understand in english ... hindi me smjhate to aacha rehta.. aur aache se smjh me aata

  • @sushantsuman4329
    @sushantsuman4329 Год назад

    why ggf output is 6 and gfg is 7? both are same

    • @PlacementsReady
      @PlacementsReady  Год назад

      Do a dry run according to algo u will understand

  • @nithinn2632
    @nithinn2632 Год назад

    in string "gfg", why "ggf" and "fgg" is not a substring?

    • @rainywinter459
      @rainywinter459 Год назад

      We are finding subsequences not substring

    • @PlacementsReady
      @PlacementsReady  Год назад

      Bro by mistake I told substring while explaining

    • @PlacementsReady
      @PlacementsReady  Год назад

      Order should be followed that's why ggf and fgg is not a subsequence

  • @ScaraB01
    @ScaraB01 Год назад

    Can u tell in python

    • @piyushverma1303
      @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
      @PlacementsReady  Год назад

      For reference Java and python code is attached in description of video