Anonymous interview question

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