Pregunta de entrevista de Blibli

Recursive Problem and logic algorithm with a most efficient solution