Pregunta de entrevista de Amazon

Recursion related question, easy to solve