[C++] | DP - Bottom UP | O(N) time, O(1) space
\ntypedef long long ll;\nclass Solution {\n    const int mod = 1e9+7;\npublic:\n    int numberOfUniqueGoodSubsequences(string s) {\n        int len = s.size();\
```\ntypedef long long ll;\nclass Solution {\n    const int mod = 1e9+7;\npublic:\n    int numberOfUniqueGoodSubsequences(string s) {\n        int len = s.size();\n        auto first=s[0]-\'0\';\n        \n        ll zero=0,one=first;\n        bool z=!first;\n        ll ans=first;\n        for(int x=1;x<len;x++){\n            auto i=s[x]-\'0\';\n            ll res=ans;\n            if(i==0){\n                z=true;\n                res=(res-zero+mod)%mod;\n                ans=(ans+res)%mod;\n                zero=(res+zero)%mod;\n            }\n            else{\n                res++;\n                res=(res-one+mod)%mod;\n                ans=(ans+res)%mod;\n                one=(res+one)%mod;\n            }   \n        }\n        return (ans+(ll)z)%mod;\n    }\n};\n```
['Dynamic Programming', 'C', 'C++']