Pergunta de entrevista da empresa Meta

Leet code question, hard difficulty level, recursion.