Pergunta de entrevista da empresa Visa Inc.

I create a recursive for loop and then optimized the solution using a dictionary