5 types of nodes in the imaginery Trie + Visualization
If we imagine a binary trie tree, there are 5 types of nodes:\n1) The "0" node, the root node of the "0" tree\n2) A node in the "1" tree that has no left child 
If we imagine a binary trie tree, there are 5 types of nodes:\n1) The "0" node, the root node of the "0" tree\n2) A node in the "1" tree that has no left child or right child (left child means "0", right child means "1")\n3) A node in the "1" tree that has left child but no right child\n4) A node in the "1" tree that has right child but no left child\n5) A node in the "1" tree that has both children\n\nEvery time if we insert into the trie tree:\n* If we have a "0":\n  * we create type 1), and also, \n  * 2) becomes 3), \n  * 4) becomes 5),\n  * 4) is gone\n* If we have a "1", then \n  * 2) becomes 4), \n  * 3) becomes 5), \n  * 3) is gone\n\n\nVisualization:\n![image](https://assets.leetcode.com/users/images/a255b001-653e-4570-a816-d8cf21a57453_1630210909.2918553.png)\n\n\nCode: (1337C0D3 Supportz Emojis so why not use them \uD83D\uDCAA\uD83D\uDE00\uD83C\uDF1A\uD83D\uDE2C\uD83D\uDE2C\uD83D\uDE2C\uD83D\uDCAA\uD83D\uDCAA\n```\nclass Solution {\npublic:\n    int \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(int a, int b) {\n        return int((long(a)+long(b)) % 1000000007L);\n    }\n    int numberOfUniqueGoodSubsequences(string binary) {\n        bool has0 = false; // does 0 exist?\n        bool has1 = false;\n        int n00 = 0; // No left child or right child\n        int n10 = 0; // has left child, no right child\n        int n01 = 0; // has right child, no left child\n        int n11 = 0; // has both children\n        \n        for (char c : binary) {\n            if (c == \'0\') {\n                has0 = true;\n            }\n           \n            if (has1) {\n                int n00_next = 0, n10_next = 0, n11_next = 0, n01_next = 0;\n                if (c == \'0\') {\n                    n00_next = \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n00, n01);\n                    n10_next = \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n10, n00);\n                    n11_next = \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n11, n01);\n                    n01_next = 0;\n                } else {\n                    n00_next = \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n00, n10);\n                    n01_next = \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n01, n00);\n                    n11_next = \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n10, n11);\n                    n10_next = 0;\n                }\n                n00 = n00_next; n10 = n10_next; n01 = n01_next; n11 = n11_next;\n            }\n            \n            if (c == \'1\') {\n                if (has1 == false) {\n                    has1 = true;\n                    n00 = 1;\n                }\n            }\n            \n            //printf("%d %d %d %d\\n", n00, n01, n10, n11);\n        }\n        return \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(int(has0), \n                \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n00,\n                 \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n10,\n                  \uD83D\uDE00\uD83D\uDE00\uD83D\uDE00(n01, n11)\n                         )\n                        )\n                       );\n    }\n};\n```
['Dynamic Programming', 'Trie']