Blibli interview question

Recursive Problem and logic algorithm with a most efficient solution