[Python] Explanation with pictures.
Take 1110001 as an example.\nLet\'s count how many new subsequences each digit brings.\n\n\n\n\n\n\nThe code is not concise, please refer to others\'.\n\n\ndef 
Take `1110001` as an example.\nLet\'s count how many **new** subsequences each digit brings.\n\n![image](https://assets.leetcode.com/users/images/e1b7d307-fab5-44bf-9713-4434e4d8cd43_1630209783.8903391.png)\n![image](https://assets.leetcode.com/users/images/f2ddaef1-c938-4219-92bb-e9a91eec0cac_1630209787.9875412.png)\n![image](https://assets.leetcode.com/users/images/752ce536-33b0-4368-b996-9646af0e1fb1_1630209791.2866592.png)\n![image](https://assets.leetcode.com/users/images/6a670b68-3248-452c-90c2-cc0cda27722e_1630209794.4180772.png)\n\nThe code is not concise, please refer to others\'.\n\n```\ndef numberOfUniqueGoodSubsequences(self, binary: str) -> int:\n        mod, n = 10 ** 9 + 7, len(binary)\n\n        one_idx, zero_idx = binary.find("1"), binary.find("0")\n        if zero_idx == -1: return n\n        if one_idx == -1: return 1\n\n        ans = [0] * n\n        ans[one_idx] = 1\n\n        for i in range(one_idx + 1, n):\n            if binary[i] != binary[i - 1]:\n                ans[i] = ans[i - 1]\n                j = i - 1\n                while j > 0 and binary[j] == binary[j - 1]: \n                    ans[i] += ans[j - 1]\n                    j -= 1\n                if j > 0: ans[i] += ans[j - 1]\n            else:\n                ans[i] = ans[i - 1]\n\n        return (sum(ans) + 1) % mod\n```\n\n\n
[]