Easy Solution
\n\n# Approach\nFirst count without zero and then add 1 if zero is in string.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n
\n\n# Approach\nFirst count without zero and then add 1 if zero is in string.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\npublic:\n    int mod = 1e9+7;\n    int numberOfUniqueGoodSubsequences(string s) {\n        int n = s.size();\n        vector<int>dp(n,0);\n        bool flag = 0;\n        int sum=0;\n        vector<int>hash(2,-1);\n        for(int i=0;i<n;i++){\n            dp[i] = sum+1;\n            sum=(sum+dp[i])%mod;\n            // cout<<sum<<endl;\n            if(hash[s[i]-\'0\']!=-1)sum=((sum-dp[hash[s[i]-\'0\']])+mod)%mod;\n            if(!flag&&s[i]==\'0\')sum--;\n            if(s[i]==\'0\')flag=1;\n            hash[s[i]-\'0\']=i;\n            // cout<<sum<<endl;\n        }\n        // for(auto&it:dp)cout<<it<<\' \';cout<<endl;\n        return sum+flag;\n    }\n};\n```
['C++']