The Easier Way | DP O(n) | Backward Iteration
Intuition\nSuppose dp[i][bit] shows number of subsequences with  all of it\'s bit indices greater or equal to i and starts with bit bit(0, 1). So, the recursive
# Intuition\nSuppose ```dp[i][bit]``` shows number of subsequences with  all of it\'s bit indices greater or equal to ```i``` and starts with bit ```bit```(0, 1). So, the recursive relation would be:\n```dp[i][bit] = dp[i + 1][0] + dp[i + 1][1] + 1```(+1 for single 1 or single zero). Therefore the optimized space solution would be like below:\n# Code\n```\nclass Solution:\n    def numberOfUniqueGoodSubsequences(self, binary: str) -> int:\n        dp = [0, 0]\n        mod = int(1e9 + 7)\n        for bit in [int(b) for b in binary][::-1]:\n            dp[bit] = (1 + sum(dp)) % mod\n        return (dp[1] + int(\'0\' in binary)) % mod\n\n```
['Python3']