Pergunta de entrevista da empresa Meta

write some code, analyze the worst case complexity