Python Simple and elegant 2 pointer DP
Assume leading zero is not allowed (including single 0 case). If we find single 0, add it back.\n\nclass Solution:\n    def numberOfUniqueGoodSubsequences(self,
Assume leading zero is not allowed (including single 0 case). If we find single 0, add it back.\n```\nclass Solution:\n    def numberOfUniqueGoodSubsequences(self, binary: str) -> int:\n        last_one=0\n        last_zero=0\n        has_zero=0\n        MOD=10**9+7\n        for i in range(len(binary)):\n            if binary[i]=="0":\n                has_zero=1\n                break\n        for i in range(len(binary)):\n            if binary[i]=="1":\n                ## leading 1 is allowed\n                ## 10,11 (next digit is 1)-> 101, 111, 1\n                ## 101,111,1-> 1011, 1111, 11\n                last_one+=last_zero+1\n            else:\n                ## leading 0 not allowed\n                ## 10,11-> 100, 110\n                last_zero+=last_one\n        return (last_one+last_zero+has_zero)%MOD\n```
['Two Pointers', 'Dynamic Programming']