Accepted || C++ || DP O(n) || Explanation with Intuition
Straight Forward DP.\n\nWhat we need?\n- Number of non empty unique subsequences of the given string, without leading zeroes\n    \n\nIntution/Approach.\n    - 
Straight Forward DP.\n\nWhat we need?\n- Number of non empty unique subsequences of the given string, without leading zeroes\n    \n```\nIntution/Approach.\n    -  A valid subsequence will have a \'1\' as MSB\n    -  Let at index i we have \'1\'. Then, \n        -  we can take all unique subsequences in [i+1, n-1], \n        -  add \'1\' to their start, we get new unique subsequences starting with \'1\'\n        \n        - Why will new generated subsequences be unique?\n            - Because we are adding same character to the start of every unique subsequence we have till now. Thus, even though, first character will be  \n            same, the subsequent part will be unique for each subsequence.\n            \n        - Are we missing any valid subsequence?\n            - Yes.\n            - Subsequence "1" . \n                - Because, we are adding to \'1\' to every subsequence, this "1" will become "11", \n                - Thats why we have to add extra one at each ith index.\n\n\t- Similarly, for index i which have \'0\'\n    \n ```           \n\n**DP States.**\n- dp[1][i] = # different good Subsequence with leading ones,  in substring [i:n-1]\n- dp[0][i] = #different good Subsequence with leading zeroes, in substring [i:n-1]\n\n\n**DP Transition.**\n- Let\'s say at index i, we have s[i] == \'1\'\n\t- Then, this leading one can be added at the beginning of all subsequences starting with \'0\' and to all subsequences starting at \'1\'.\n\t-  As, explained in the intution, whenever we add a character to the beginning, we loose, subsequence "1"\n\t-  dp[1][i] = (dp[0][i+1]+dp[1][i+1]+1)\n-  Similarily, for the case s[i] == \'0\'\n    \n\n**TC** - O(n)\n**SC** - O(n), can be optimised to O(1)\n```\n#define ll long long\nint mod = 1e9 + 7;\n\nclass Solution {\npublic:\n    int numberOfUniqueGoodSubsequences(string s) {\n        int n = s.length(), ans = 0, first = n, zero = 0;\n        \n        vector<vector<int>> dp(2,vector<int>(n+1, 0));    \n        \n        for(int i=n-1; i>=0; --i){\n            if(s[i]==\'0\') {\n                zero = 1;\n                dp[0][i] = (1ll*dp[0][i+1] + 1ll + dp[1][i+1])%mod;\n                dp[1][i] = dp[1][i+1];\n            }\n            else {\n                dp[1][i] = (1ll*dp[0][i+1] + 1ll + dp[1][i+1])%mod;\n                dp[0][i] = dp[0][i+1];\n            }\n        }\n        \n        return (dp[1][0] + zero)%mod;\n                \n    }\n};\n```
[]