Python, runtime O(n), memory O(1)
Got idea here: https://leetcode.com/problems/number-of-unique-good-subsequences/solutions/1431802/c-clean-dp-solution-with-explanation-time-o-n-space-o-1/\n\ncl
Got idea here: https://leetcode.com/problems/number-of-unique-good-subsequences/solutions/1431802/c-clean-dp-solution-with-explanation-time-o-n-space-o-1/\n```\nclass Solution:\n    def numberOfUniqueGoodSubsequences(self, binary: str) -> int:\n        end0 = end1 = hasZero = 0\n        mod = 10**9+7\n        for e in binary:\n            if e == \'0\':\n                hasZero = 1\n                end0 = end0 + end1\n            else:\n                end1 = end0 + end1 + 1\n        return (hasZero + end0 + end1)%mod\n```
['Python3']