C++, reverse, no. of distinct sub sequences ending at 1
\n\nint numberOfUniqueGoodSubsequences(string binary) {\n        unsigned long long dp[2] = {0};\n        reverse(binary.begin(), binary.end());\n        bool z
```\n\nint numberOfUniqueGoodSubsequences(string binary) {\n        unsigned long long dp[2] = {0};\n        reverse(binary.begin(), binary.end());\n        bool zero = false;\n        const long long mod = 1e9 + 7;\n        for (char &c: binary) {\n            dp[c - \'0\'] = dp[0] + dp[1] + 1LL;\n            dp[c - \'0\'] %= mod;\n            zero = zero || c == \'0\';\n        }\n        return (dp[1] + zero) % mod;\n    }\n\n\n```
[]