C++ 6 liners concise O(n) time solution beats 100% with explanation
Idea: remove all prefix 0s first (and ues has zero to check if there are at least one 0s\n1. p0 is the number of unique good subsequences ends with 0\n-> if an 
Idea: remove all prefix 0s first (and ues has zero to check if there are at least one 0s\n1. p0 is the number of unique good subsequences ends with 0\n-> if an 0 is encountered, it is updated with p0=p0+p1\n-> because the new subsequence can be prefixed by subsequences ended with "0" (eg. p0) or "1" (eg. p1)\n2. p1 is te number of unique good sequences ends with 1\n-> if an 1 is encountered, it is updated with p1=p0+p1+1\n-> because the new subsequence can be prefixed by subsequences ended with "0" (eg. p0) or "1" (eg. p1) or nothing (eg. 1)\n3. if there is a zero, add 1 to the result\n\nNote: no need to add 1 to p0 because the subsequence can not be prefixed by "0" (eg. no need to accumulate forward)\n```\nint numberOfUniqueGoodSubsequences(string& binary) \n{\n\tint n=binary.length(),p0=0,p1=0,d=1000000007;\n\tbool has_zero=false;\n\n\tfor(int i=0;i<n;i++)\n\t\tif(binary[i]==\'0\') has_zero=true,p0=(p0+p1)%d;\n\t\telse p1=(p0+p1+1)%d;\n\n\treturn (p0+p1+has_zero)%d;\n}\n```
[]