C++ O(n) time O(1) space solution
\nclass Solution {\npublic:\n    int numberOfUniqueGoodSubsequences(string s) {\n        unsigned long long prevo=0;\n         unsigned long long prevz=0;\n    
```\nclass Solution {\npublic:\n    int numberOfUniqueGoodSubsequences(string s) {\n        unsigned long long prevo=0;\n         unsigned long long prevz=0;\n       unsigned long long ans=0;\n        int ff=-1;\n        int f=0;\n        int mod=1000000007;\n        for(int i=0;i<s.size();i++)\n            \n        {\n            if(s[i]==\'0\')\n            {\n                int x=ans;\n                ans+=mod+ans-prevz ;\n                prevz=x;\n                f=1;\n                ans=ans%mod;\n            }\n            else\n            { \n                int x=ans;\n                if(ff==-1) {ans=1;ff=1;}\n                else\n                ans+=mod+ans-prevo;\n                ans=ans%mod;\n                prevo=x;\n            }\n        }\n        return (ans+ f)%mod;\n    }\n};\n```
[]