Anonymous Interview Question

String with recursion, optimal solution would include dynamic programming or trie.