C++ | O(n) time O(1) space
\nclass Solution {\npublic:\n    long md=1e9+7;\n    int numberOfUniqueGoodSubsequences(string binary) {\n        long zo=0,o=0,z=0;\n        \n        long ans
```\nclass Solution {\npublic:\n    long md=1e9+7;\n    int numberOfUniqueGoodSubsequences(string binary) {\n        long zo=0,o=0,z=0;\n        \n        long ans=0;\n        \n        for(auto &ch:binary) if(ch==\'0\') ans=1;\n        \n        int l=0;\n        \n        while(l<binary.length() and binary[l]==\'0\') l++;\n        \n        if(l==binary.length()) return ans;\n        \n        zo=1;\n        \n        l++;\n        \n        while(l<binary.length()){\n            if(binary[l]==\'0\'){\n               ans+=z;\n                o+=zo;\n                zo+=z;\n                z=0;\n                \n            }\n            else{\n                ans+=o;\n                z+=zo;\n                zo+=o;\n                o=0;\n                \n            }\n            l++;\n            ans=ans%md;\n            zo=zo%md;                                                         \n        }\n        ans=(ans+zo+z+o)%md;\n        return ans;\n        \n    }\n};\n```
['C', 'C++']