Pergunta de entrevista da empresa TikTok

Solved a coding recursive question