C++ dynamic programming with state compression 19ms
\nclass Solution {\npublic:\n    int numberOfUniqueGoodSubsequences(string binary) {\n        long endswith[2] = {}, mod = 1e9+7;\n        \n        bool haszer
```\nclass Solution {\npublic:\n    int numberOfUniqueGoodSubsequences(string binary) {\n        long endswith[2] = {}, mod = 1e9+7;\n        \n        bool haszero = false;\n        for (char& c: binary) {\n            haszero |= (c == \'0\');\n            endswith[c-\'0\'] = (endswith[0] + endswith[1] + (c == \'0\'?0L:1L)) % mod;\n        }\n        return (endswith[0] + endswith[1]) % mod + haszero;\n    }\n};\n```
['Dynamic Programming', 'C']