Python Simple DP Solution
We start with "0" then stop, only one subsequence. Otherwise, on each position, we have two choices, either take it or not take it\n\nBut how to avoid duplicate
We start with "0" then stop, only one subsequence. Otherwise, on each position, we have two choices, either take it or not take it\n\nBut how to avoid duplicates ?\n\ndp[i][j]= no of distinct subsequences starting with (i=0/1) and ends with (j=0/1) or look likes [i...j]\n\nans= dp[0][0]+dp[0][1]+dp[1][0]+dp[1][1]\n\nif s[i]==\'0\', we stick this \'0\' to all subsequences of type [1....0] and [1...1]. So, dp[1][0] increases to dp[1][0]+dp[1][1]. Also we can make one subsequence of type "0" (dp[0][0]). So we make dp[0][0]=1\n\n(NOTE subsequence of type [0...1] is not valid)\n\nif s[i]==\'1\', we stick this \'1\' to all subsequences of type [1...0] and [1....1], also, we can get one new subsequence that is "1". So dp[1][1] increases to dp[1][0]+dp[1][1]+1\n\nans= dp[0][0]+dp[0][1]+dp[1][0]+dp[1][1]\n\n```\nclass Solution:\n    def numberOfUniqueGoodSubsequences(self, binary: str) -> int:\n        dp, sz = [[0, 0], [0, 0]], len(binary)\n        for bit in binary:\n            if bit == \'0\':\n                dp[0][0] = 1\n                dp[1][0] += dp[1][1]\n            else:\n                dp[1][1] += (dp[1][0] + 1)\n        return (dp[0][0] + dp[0][1] + dp[1][0] + dp[1][1]) % 1000000007\n```
['Dynamic Programming', 'Python']