C++ DP solution
\nclass Solution {\npublic:\n    const int mod = 1e9 + 7;\n    int numberOfUniqueGoodSubsequences(string binary) {\n        int n = binary.size();\n        vect
```\nclass Solution {\npublic:\n    const int mod = 1e9 + 7;\n    int numberOfUniqueGoodSubsequences(string binary) {\n        int n = binary.size();\n        vector<int> dp(n + 1);\n        dp[n] = 1;\n        int one = -1;\n        int zero = -1;\n        for (int i = n - 1; i >= 0; i--) {\n            if (binary[i] == \'1\') {\n                dp[i] = (2 * dp[i + 1]) % mod;\n                if (one != -1) {\n                    dp[i] -= dp[one + 1];\n                    if (dp[i] < 0) {\n                        dp[i] += mod;\n                    }\n                }\n                one = i;\n            }\n            else {\n                dp[i] = (2 * dp[i + 1]) % mod;\n                if (zero != -1) {\n                    dp[i] -= dp[zero + 1];\n                    if (dp[i] < 0) {\n                        dp[i] += mod;\n                    }\n                }\n                zero = i;\n            }\n        }\n        int sol = dp[0] - 1;\n        if (sol < 0) {\n            sol += mod;\n        }\n        for (int i = 0; i < n; i++) {\n            if (binary[i] == \'0\') {\n                sol -= dp[i + 1];\n                if (sol < 0) {\n                    sol += mod;\n                }\n                sol = (sol + 1) % mod;\n                break;\n            }\n        }\n        return sol;\n    }\n};\n```
[]