[C++] clean code, DP with O(1) space
We can iterate from the last character to the begin and store the previous zeros and ones.\nBecause the good subsequences must start from \'1\' except subsequen
We can iterate from the last character to the begin and store the previous zeros and ones.\nBecause the good subsequences must start from \'1\' except subsequence \'0\', we can just store current zeros and ones.\nAt the end, number of one will be the number of good subsequences. Besides, we have to check the edge case \'0\'.\n```\nclass Solution {\n    int MOD = 1000000007;\npublic:\n    int numberOfUniqueGoodSubsequences(string binary) {\n        int zero = 0;\n        long long ones = 0;\n        long long zeros = 0;\n        \n        for (int i = binary.size() - 1; i >= 0; --i) {\n            if (binary[i] == \'1\') {\n                ones = (ones + zeros + 1) % MOD;\n            } else {\n                zero = 1;\n                zeros = (ones + zeros + 1) % MOD;\n            }\n        }\n        return (ones + zero) % MOD;\n    }\n};\n```
['Dynamic Programming', 'C']