Pergunta de entrevista da empresa Duolingo

questions about time/space complexity for some code