Pergunta de entrevista da empresa Anonymous

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