O(n) dp, just reverse iterate
Intuition\n Describe your first thoughts on how to solve this problem. \nreversly iterate the array, if it is 0, we know, it is invalid, but can contribute to l
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nreversly iterate the array, if it is 0, we know, it is invalid, but can contribute to later 1\'s subsequences, so we store the amount of ending 0, subsequnces\nif it is 1, we use previous n0 and n1 subsequence and plus 1, because the unique 1 <- s[i], it can be later contribute or as single unique character. \nwe only return the result that start with 1, so return n0, and if there is single 0, we add 1. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimpl Solution {\n    pub fn number_of_unique_good_subsequences(binary: String) -> i32 {\n        //dp[i][0] <- the number of subsequence start by 0 at i\n        //dp[i][1] <- the number of subsequence start by 1 at i\n        //dp[i][1] = dp[i + 1][0] + dp[i + 1][1]\n        //dp[i][0] = dp[i + 1][0] + dp[i + 1][1]\n        let n = binary.len();\n        let binary = binary.as_bytes();\n        let mut has0 = 0;\n        let mut n0 = 0;\n        let mut n1 = 0;\n        let m = 1e9 as i32 + 7;\n        for i in (0..n).rev(){\n            if binary[i] == b\'1\'{\n                n1 = (n0 + n1 + 1)%m;\n            }else{\n                n0 = (n0 + n1 + 1)%m;\n                has0 = 1;\n            }\n        }\n        return (n1 + has0)%m;\n    } \n}\n```
['Rust']