parameters: (self, S)
return_statement: return result
docstring: :type S: str
          :rtype: int
docstring_summary: :type S: str
          :rtype: int
docstring_tokens: : type S : str : rtype : int
function: def distinctSubseqII(self, S):
          """
          :type S: str
          :rtype: int
          """
          MOD = 10**9+7
          result, dp = 0, [0]*26
          for c in S:
              result, dp[ord(c)-ord('a')] = (result+((result+1)-dp[ord(c)-ord('a')]))%MOD, (result+1)%MOD
          return result
function_tokens: def distinctSubseqII ( self , S ) : MOD = 10 ** 9 + 7 result , dp = 0 , [ 0 ] * 26 for c in S : result , dp [ ord ( c ) - ord ( 'a' ) ] = ( result + ( ( result + 1 ) - dp [ ord ( c ) - ord ( 'a' ) ] ) ) % MOD , ( result + 1 ) % MOD return result