Nice DP approach in C++
class Solution {\npublic:\n    int numberOfUniqueGoodSubsequences(string binary) {\n        \n        int n = binary.length();\n        \n        long long MOD 
class Solution {\npublic:\n    int numberOfUniqueGoodSubsequences(string binary) {\n        \n        int n = binary.length();\n        \n        long long MOD = 1000000007;\n        \n        vector< long long > DP( n+1 , 1);\n        \n        bool leadingZeroes = true;\n        bool hasZero = false;\n        \n        vector< long long >count( 2, 0 );\n        \n        for( int i = 1 ; i<=n ; i++ ){\n\n            long long repeat = count[ binary[i-1] == \'0\' ? 0 : 1 ]; \n            \n            if(binary[ i-1 ] == \'0\' ){\n                hasZero = true;\n                repeat ++; \n            }\n            \n            if( leadingZeroes && binary[ i-1 ] == \'0\' ) continue;\n            \n            if( leadingZeroes && binary[ i-1 ] == \'1\' )\n                 leadingZeroes = false;\n             \n            DP[ i ] = ( DP[ i-1 ] * 2 - repeat )%MOD;\n            \n            if( DP[i] < 0 )\n                DP[ i ] += MOD;\n            \n            count[ binary[i-1] == \'0\' ? 0 : 1 ] += DP[i] - DP[i-1];  \n        }\n        \n        return ( hasZero ?  DP[n]  : DP[n]-1 )%MOD; \n    }\n};\n\n// minus parts ::\n\n//   a) no leading zeroes except 0\n//   b) unique subsequences\n\n// *    0     0      1      1     0      1      0       1  \n// 1    2     4\n\n// 0 -> 1\n// 1 ->
[]