Python Soln - DP O(n)
\tclass Solution:\n\t\tdef numberOfUniqueGoodSubsequences(self, binary: str) -> int:\n\t\t\tn = len(binary)\n\t\t\ts = 0\n\t\t\tmod = (109)+7\n\t\t\t#Time O(n),
\tclass Solution:\n\t\tdef numberOfUniqueGoodSubsequences(self, binary: str) -> int:\n\t\t\tn = len(binary)\n\t\t\ts = 0\n\t\t\tmod = (10**9)+7\n\t\t\t#Time O(n), Space O(n)\n\t\t\t# increase s while there are leading zeros\n\t\t\twhile s < n and binary[s] == \'0\':\n\t\t\t\ts += 1\n\n\t\t\tif s == n:\n\t\t\t\treturn 1\n\n\t\t\tdp = [0]*n\n\t\t\tdp[s] = 1\n\t\t\tlastZero = lastOne = 0\n\n\t\t\tfor i in range(s+1, n):\n\t\t\t\tj = lastZero if binary[i] == \'0\' else lastOne\n\t\t\t\tdup = dp[j-1] if j > 0 else 0\n\n\t\t\t\tdp[i] = 2*dp[i-1] - dup #num of unique subseq\n\n\t\t\t\tif binary[i] == \'0\':\n\t\t\t\t\tlastZero = i\n\t\t\t\telse:\n\t\t\t\t\tlastOne = i\n\n\t\t\tlastZero = 0 \n\t\t\t#add one zero from the leading zeros as a unique subseq\n\t\t\tif \'0\' in binary:\n\t\t\t\tlastZero += 1\n\n\t\t\treturn (dp[-1] + lastZero) % mod
[]